|
|
@@ -1,148 +1,16 @@
|
|
|
/* Grafana Alloy Configuration Examples
|
|
|
* ---
|
|
|
* LINK: For more details, visit https://github.com/grafana/alloy-scenarios
|
|
|
-*/
|
|
|
|
|
|
-// SECTION: TARGETS
|
|
|
-
|
|
|
-loki.write "default" {
|
|
|
- endpoint {
|
|
|
- url = "http://loki:3100/loki/api/v1/push"
|
|
|
- }
|
|
|
- external_labels = {}
|
|
|
-}
|
|
|
-
|
|
|
-prometheus.remote_write "default" {
|
|
|
- endpoint {
|
|
|
- url = "http://prometheus:9090/api/v1/write"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// !SECTION
|
|
|
-
|
|
|
-// SECTION: 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]
|
|
|
-}
|
|
|
-
|
|
|
-// !SECTION
|
|
|
-
|
|
|
-// SECTION: SYSTEM 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"]
|
|
|
- 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_timeout = "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]
|
|
|
-}
|
|
|
-
|
|
|
-// !SECTION
|
|
|
-
|
|
|
-// SECTION: DOCKER METRICS
|
|
|
-
|
|
|
-prometheus.exporter.cadvisor "dockermetrics" {
|
|
|
- docker_host = "unix:///var/run/docker.sock"
|
|
|
- storage_duration = "5m"
|
|
|
-}
|
|
|
-
|
|
|
-prometheus.scrape "dockermetrics" {
|
|
|
- targets = prometheus.exporter.cadvisor.dockermetrics.targets
|
|
|
- forward_to = [ prometheus.remote_write.default.receiver ]
|
|
|
- scrape_interval = "10s"
|
|
|
-}
|
|
|
-
|
|
|
-//!SECTION
|
|
|
-
|
|
|
-// SECTION: DOCKER 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]
|
|
|
-}
|
|
|
-
|
|
|
-// !SECTION
|
|
|
+ * This file intentionally contains no pipeline/function definitions.
|
|
|
+ * Use the sub-templates to generate specific configuration fragments:
|
|
|
+ * - alloy.system-logs
|
|
|
+ * - alloy.system-metrics
|
|
|
+ * - alloy.docker-metrics
|
|
|
+ * - alloy.docker-logs
|
|
|
+ *
|
|
|
+ * When generating a full configuration you can concatenate the generated
|
|
|
+ * fragments into `config/config.alloy` or manage them as separate files.
|
|
|
+ */
|
|
|
+
|
|
|
+// Minimal placeholder - no functions here by design.
|