-
Notifications
You must be signed in to change notification settings - Fork 7
/
logs.alloy
97 lines (75 loc) · 2.9 KB
/
logs.alloy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
logging {
level = coalesce(sys.env("ALLOY_LOG_LEVEL"), "warn")
format = "logfmt"
}
/********************************************
* Grafana LGTMP Stack Receiver Provider
********************************************/
import.git "provider" {
repository = "https://github.com/qclaogui/codelab-monitoring.git"
revision = "main"
path = "alloy-modules/provider"
pull_frequency = "24h"
}
provider.self_hosted_stack "kubernetes" {
metrics_endpoint_url = coalesce(sys.env("SELF_HOSTED_METRICS_ENDPOINT_URL"), "http://nginx.gateway.svc:8080/api/v1/push")
logs_endpoint_url = coalesce(sys.env("SELF_HOSTED_LOGS_ENDPOINT_URL"), "http://nginx.gateway.svc:3100/loki/api/v1/push")
}
/********************************************
* Logs
********************************************/
import.file "logs" {
filename = coalesce(sys.env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/logs"
}
logs.rules_to_loki "kubernetes" { }
logs.kubernetes_cluster_events "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
forward_to = [logs.keep_labels.kubernetes.receiver]
}
logs.annotations_scrape "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
forward_to = [logs.keep_labels.kubernetes.receiver]
}
logs.keep_labels "kubernetes" {
forward_to = [provider.self_hosted_stack.kubernetes.logs_receiver]
}
/********************************************
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(sys.env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics"
}
metrics.rules_to_mimir "kubernetes" { }
metrics.annotations_scrape "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
scrape_interval = "15s"
forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]
}
metrics.servicemonitors_scrape "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
scrape_interval = "15s"
forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]
}
// Jobs metrics
import.file "jobs" {
filename = coalesce(sys.env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/jobs"
}
jobs.kubelet_metrics_scrape "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
scrape_interval = "30s"
forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]
}
// Alloy integration metrics
remote.kubernetes.configmap "integrations" {
namespace = "monitoring-system"
name = "alloy-integrations"
}
// Memcached Integrations
import.string "memcached" {
content = remote.kubernetes.configmap.integrations.data["memcached.alloy"]
}
memcached.memcached_metrics_scrape "instance" {
namespace = "monitoring-system"
name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"]
forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]
}