-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrafana_cloud.alloy
95 lines (80 loc) · 2.54 KB
/
grafana_cloud.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
// Pilfered from https://github.com/grafana/alloy-modules/blob/main/modules/cloud/grafana/cloud/module.alloy
// Modified to be able to set external labels on receivers.
declare "stack" {
argument "stack_name" {
comment = "The name of the grafana cloud stack to get the configuration from."
}
argument "token" {
comment = "The token to authenticate with the Grafana Cloud API."
}
argument "external_labels" {
comment = "External labels to add to receivers created in this module."
}
// Get the configuration from the Grafana Cloud API
remote.http "config" {
url = "https://grafana.com/api/instances/" + argument.stack_name.value
client {
bearer_token = argument.token.value
}
poll_frequency = "24h"
}
// Setup the prometheus remote write receiver
prometheus.remote_write "default" {
external_labels = argument.external_labels.value
endpoint {
url = json_decode(remote.http.config.content)["hmInstancePromUrl"] + "/api/prom/push"
basic_auth {
username = json_decode(remote.http.config.content)["hmInstancePromId"]
password = argument.token.value
}
}
}
// Setup the loki write receiver
loki.write "default" {
external_labels = argument.external_labels.value
endpoint {
url = json_decode(remote.http.config.content)["hlInstanceUrl"] + "/loki/api/v1/push"
basic_auth {
username = json_decode(remote.http.config.content)["hlInstanceId"]
password = argument.token.value
}
}
}
// Setup the traces receiver
otelcol.auth.basic "default" {
username = json_decode(remote.http.config.content)["htInstanceId"]
password = argument.token.value
}
otelcol.exporter.otlp "default" {
client {
endpoint = json_decode(remote.http.config.content)["htInstanceUrl"] + ":443"
auth = otelcol.auth.basic.default.handler
}
}
// Setup the pyroscope write receiver
pyroscope.write "default" {
endpoint {
url = json_decode(remote.http.config.content)["hpInstanceUrl"]
basic_auth {
username = json_decode(remote.http.config.content)["hpInstanceId"]
password = argument.token.value
}
}
}
// Export the receivers
export "metrics" {
value = prometheus.remote_write.default.receiver
}
export "logs" {
value = loki.write.default.receiver
}
export "traces" {
value = otelcol.exporter.otlp.default.input
}
export "profiles" {
value = pyroscope.write.default.receiver
}
export "info" {
value = json_decode(remote.http.config.content)
}
}