-
Notifications
You must be signed in to change notification settings - Fork 7
/
profiles.alloy
83 lines (66 loc) · 2.58 KB
/
profiles.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
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")
profiles_endpoint_url = coalesce(sys.env("SELF_HOSTED_PROFILES_ENDPOINT_URL"), "http://nginx.gateway.svc:4040")
}
/********************************************
* Profiles
********************************************/
import.file "profiles" {
filename = coalesce(sys.env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/profiles"
}
profiles.annotations_scrape "kubernetes" {
cluster = coalesce(sys.env("CLUSTER_NAME"), "k3d-k3s-codelab")
forward_to = [provider.self_hosted_stack.kubernetes.profiles_receiver]
}
/********************************************
* Metrics
********************************************/
import.file "metrics" {
filename = coalesce(sys.env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics"
}
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]
}