Skip to content

Commit 12086f2

Browse files
committed
Add Elasticsearch Exporter to Alloy
1 parent bfe035c commit 12086f2

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,12 @@
2424
// "remoteUser": "root"
2525
"workspaceFolder": "${localWorkspaceFolder}",
2626
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"Grafana.grafana-alloy"
31+
]
32+
}
33+
},
2734

2835
}

observability/examples/alloy/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ services:
5454
ports:
5555
- "12345:12345"
5656
volumes:
57-
- ${BASE_DIR-.}/grafana-alloy/config.alloy:/etc/alloy/config.alloy
57+
- ${BASE_DIR-.}/grafana-alloy:/etc/alloy
58+
# - ${BASE_DIR-.}/grafana-alloy/advanced/elasticsearch.alloy:/etc/alloy/elasticsearch.alloy # Enable Elastic Exporter
5859
# CAdvisor
5960
- /:/rootfs:ro
6061
- /var/run:/var/run:rw
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
prometheus.exporter.elasticsearch "elasticsearch" {
3+
address = "https://host.docker.internal:9200"
4+
basic_auth {
5+
username = sys.env("ELASTICSEARCH_USERNAME")
6+
password = sys.env("ELASTICSEARCH_PASSWORD")
7+
}
8+
ssl_skip_verify = true
9+
10+
}
11+
discovery.relabel "elasticsearch" {
12+
targets = prometheus.exporter.elasticsearch.elasticsearch.targets
13+
14+
rule {
15+
target_label = "cluster"
16+
replacement = "elasticsearch-cogstack-cluster"
17+
}
18+
rule {
19+
target_label = "host"
20+
replacement = "elasticsearch_host"
21+
}
22+
}
23+
24+
prometheus.scrape "elasticsearch_exporter" {
25+
scrape_interval = "15s"
26+
targets = discovery.relabel.elasticsearch.output
27+
forward_to = [prometheus.remote_write.default.receiver]
28+
29+
}

observability/examples/alloy/grafana-alloy/config.alloy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ logging {
33
format = "logfmt"
44
}
55

6+
livedebugging {
7+
enabled = true
8+
}
9+
610
prometheus.remote_write "default" {
711
endpoint {
812
url = sys.env("PROMETHEUS_URL")
913
}
1014
external_labels = {
1115
host = sys.env("ALLOY_HOSTNAME"),
1216
ip_address = sys.env("ALLOY_IP_ADDRESS"),
13-
}
17+
}
1418
}
1519

1620
prometheus.scrape "exporter" {

observability/examples/alloy/grafana-alloy/elasticsearch.alloy

Whitespace-only changes.

0 commit comments

Comments
 (0)