|
|
@@ -1,205 +0,0 @@
|
|
|
-/* Grafana Alloy Configuration
|
|
|
- * ---
|
|
|
- * Generated by boilerplates CLI
|
|
|
- *
|
|
|
- * This configuration file is dynamically generated based on your selected
|
|
|
- * log and metrics collection options.
|
|
|
- *
|
|
|
- * For more details, visit https://github.com/grafana/alloy-scenarios
|
|
|
- */
|
|
|
-
|
|
|
-// Disable internal traces that are trying to export to Tempo by default
|
|
|
-otelcol.exporter.otlp "tempo" {
|
|
|
- client {
|
|
|
- endpoint = "localhost:4317"
|
|
|
- tls {
|
|
|
- insecure = true
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-{% if logs_enabled or metrics_enabled %}
|
|
|
-// ============================================================================
|
|
|
-// REMOTE ENDPOINTS
|
|
|
-// ============================================================================
|
|
|
-
|
|
|
-{% if logs_enabled %}
|
|
|
-/* Loki Write Endpoint */
|
|
|
-loki.write "default" {
|
|
|
- endpoint {
|
|
|
- url = "{{ logs_loki_url }}"
|
|
|
-
|
|
|
- // Batching configuration to reduce request volume and prevent rate limiting
|
|
|
- batch_wait = "5s" // Wait up to 5 seconds before sending
|
|
|
- batch_size = "1MiB" // Send when batch reaches 1MB (1048576 bytes)
|
|
|
- }
|
|
|
- external_labels = {}
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% if metrics_enabled %}
|
|
|
-/* Prometheus Remote Write Endpoint */
|
|
|
-prometheus.remote_write "default" {
|
|
|
- endpoint {
|
|
|
- url = "{{ metrics_prometheus_url }}"
|
|
|
- }
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% if logs_enabled %}
|
|
|
-// ============================================================================
|
|
|
-// LOG COLLECTION
|
|
|
-// ============================================================================
|
|
|
-
|
|
|
-{% if logs_docker %}
|
|
|
-/* Docker Container Logs */
|
|
|
-discovery.docker "dockerlogs" {
|
|
|
- host = "unix:///var/run/docker.sock"
|
|
|
-}
|
|
|
-
|
|
|
-discovery.relabel "dockerlogs" {
|
|
|
- targets = []
|
|
|
-
|
|
|
- rule {
|
|
|
- source_labels = ["__meta_docker_container_name"]
|
|
|
- regex = "/(.*)"
|
|
|
- target_label = "service_name"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-loki.source.docker "default" {
|
|
|
- host = "unix:///var/run/docker.sock"
|
|
|
- targets = discovery.docker.dockerlogs.targets
|
|
|
- labels = {"platform" = "docker"}
|
|
|
- relabel_rules = discovery.relabel.dockerlogs.rules
|
|
|
- forward_to = [loki.write.default.receiver]
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% if logs_system %}
|
|
|
-/* System Logs & Journal */
|
|
|
-loki.source.journal "journal" {
|
|
|
- max_age = "24h0m0s"
|
|
|
- relabel_rules = discovery.relabel.journal.rules
|
|
|
- forward_to = [loki.write.default.receiver]
|
|
|
- labels = {component = string.format("%s-journal", constants.hostname)}
|
|
|
- // NOTE: This is important to fix https://github.com/grafana/alloy/issues/924
|
|
|
- path = "/var/log/journal"
|
|
|
-}
|
|
|
-
|
|
|
-local.file_match "system" {
|
|
|
- path_targets = [{
|
|
|
- __address__ = "localhost",
|
|
|
- __path__ = "/var/log/{syslog,messages,*.log}",
|
|
|
- instance = constants.hostname,
|
|
|
- job = string.format("%s-logs", constants.hostname),
|
|
|
- }]
|
|
|
-}
|
|
|
-
|
|
|
-discovery.relabel "journal" {
|
|
|
- targets = []
|
|
|
- rule {
|
|
|
- source_labels = ["__journal__systemd_unit"]
|
|
|
- target_label = "unit"
|
|
|
- }
|
|
|
- rule {
|
|
|
- source_labels = ["__journal__boot_id"]
|
|
|
- target_label = "boot_id"
|
|
|
- }
|
|
|
- rule {
|
|
|
- source_labels = ["__journal__transport"]
|
|
|
- target_label = "transport"
|
|
|
- }
|
|
|
- rule {
|
|
|
- source_labels = ["__journal_priority_keyword"]
|
|
|
- target_label = "level"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-loki.source.file "system" {
|
|
|
- targets = local.file_match.system.targets
|
|
|
- forward_to = [loki.write.default.receiver]
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% if metrics_enabled %}
|
|
|
-// ============================================================================
|
|
|
-// METRICS COLLECTION
|
|
|
-// ============================================================================
|
|
|
-
|
|
|
-{% if metrics_docker %}
|
|
|
-/* Docker Container Metrics (cAdvisor) */
|
|
|
-prometheus.exporter.cadvisor "dockermetrics" {
|
|
|
- docker_host = "unix:///var/run/docker.sock"
|
|
|
- storage_duration = "5m"
|
|
|
-}
|
|
|
-
|
|
|
-/* Relabel component to drop container_spec metrics that often have NaN values */
|
|
|
-prometheus.relabel "docker_filter" {
|
|
|
- forward_to = [prometheus.remote_write.default.receiver]
|
|
|
-
|
|
|
- rule {
|
|
|
- source_labels = ["__name__"]
|
|
|
- regex = "container_spec_(cpu_period|cpu_quota|cpu_shares|memory_limit_bytes|memory_swap_limit_bytes|memory_reservation_limit_bytes)"
|
|
|
- action = "drop"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-prometheus.scrape "dockermetrics" {
|
|
|
- targets = prometheus.exporter.cadvisor.dockermetrics.targets
|
|
|
- forward_to = [prometheus.relabel.docker_filter.receiver]
|
|
|
- scrape_interval = "10s"
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% if metrics_system %}
|
|
|
-/* System (Node) Metrics */
|
|
|
-discovery.relabel "metrics" {
|
|
|
- targets = prometheus.exporter.unix.metrics.targets
|
|
|
- rule {
|
|
|
- target_label = "instance"
|
|
|
- replacement = constants.hostname
|
|
|
- }
|
|
|
- rule {
|
|
|
- target_label = "job"
|
|
|
- replacement = string.format("%s-metrics", constants.hostname)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-prometheus.exporter.unix "metrics" {
|
|
|
- disable_collectors = ["ipvs", "btrfs", "infiniband", "xfs", "zfs"]
|
|
|
- enable_collectors = ["meminfo"]
|
|
|
- rootfs_path = "/rootfs"
|
|
|
- filesystem {
|
|
|
- fs_types_exclude = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|tmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
|
|
|
- mount_points_exclude = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)"
|
|
|
- mount_out = "5s"
|
|
|
- }
|
|
|
- netclass {
|
|
|
- ignored_devices = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
|
- }
|
|
|
- netdev {
|
|
|
- device_exclude = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-prometheus.scrape "metrics" {
|
|
|
- scrape_interval = "15s"
|
|
|
- targets = discovery.relabel.metrics.output
|
|
|
- forward_to = [prometheus.remote_write.default.receiver]
|
|
|
-}
|
|
|
-{% endif %}
|
|
|
-{% endif %}
|
|
|
-
|
|
|
-{% else %}
|
|
|
-// ============================================================================
|
|
|
-// NO COLLECTION ENABLED
|
|
|
-// ============================================================================
|
|
|
-//
|
|
|
-// No log or metrics collection is currently enabled.
|
|
|
-// To enable collection, set logs_enabled or metrics_enabled to true when
|
|
|
-// generating this template.
|
|
|
-//
|
|
|
-// For more information, visit: https://grafana.com/docs/alloy/latest/
|
|
|
-{% endif %}
|