Skip to content

Commit

Permalink
Add node exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Apr 13, 2024
1 parent c623836 commit c120a52
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 75 deletions.
80 changes: 5 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,84 +31,14 @@ $ systemctl enable docker
$ docker-compose up -d
```


### Grafana Agent

[Grafana Agent](https://github.com/grafana/agent) is a vendor-neutral, batteries-included telemetry collector with configuration inspired by Terraform. It is designed to be flexible, performant, and compatible with multiple ecosystems such as Prometheus and OpenTelemetry.

1. To install the agent in a flow mode.
3. To install Node Exporter.

```zsh
$ wget https://github.com/grafana/agent/releases/download/v0.39.1/grafana-agent-flow-0.39.1-1.amd64.deb
$ dpkg -i grafana-agent-flow-0.39.1-1.amd64.deb
```
# For Linux VM
$ ./node_exporter/linux_amd64

2. Update config file

```zsh
$ vim /etc/grafana-agent-flow.river
```

```hcl
logging {
level = "debug"
}
prometheus.remote_write "default" {
endpoint {
url = "http://127.0.0.1:9090/api/v1/write"
basic_auth {
username = "admin"
password = "password"
}
}
}
prometheus.scrape "linux_node" {
scrape_interval = "15s"
targets = prometheus.exporter.unix.node.targets
forward_to = [
prometheus.remote_write.default.receiver,
]
metrics_path = "/metrics"
}
prometheus.scrape "agent" {
targets = [
{"__address__" = "127.0.0.1:12345"},
]
forward_to = [
prometheus.remote_write.default.receiver
]
}
prometheus.exporter.unix "node" {
set_collectors = [
"vmstat",
"filesystem",
"cpu",
"uname",
"diskstats",
"loadavg",
"meminfo",
"netstat",
]
enable_collectors = [
"processes",
"systemd",
]
include_exporter_metrics = true
}
```

The above [configurations are shared on this link](https://grafana.github.io/agent-configurator/?c=Ly8gV2VsY29tZSB0byB0aGUgR3JhZmFuYSBBZ2VudCBDb25maWd1cmF0b3IhCi8vIFlvdSBjYW4gcGFzdGUgeW91ciBjb25maWd1cmF0aW9uIGhlcmUgb3Igc3RhcnQgYnkgdXNpbmcgdGhlIGNv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bmFibGVfY29sbGVjdG9ycyA9IFsKICAgICJwcm9jZXNzZXMiLAogICAgInN5c3RlbWQiLAogIF0KICBpbmNsdWRlX2V4cG9ydGVyX21ldHJpY3MgPSB0cnVlCn0=)

3. Start the grafana agent service

```zsh
$ systemctl start grafana-agent-flow
$ systemctl status grafana-agent-flow
# For Linux RPI
$ ./node_exporter/linux_arm64
```


Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions node_exporter/linux_arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

function node_exporter {
echo "Installing node_exporter ..."

groupadd -f node_exporter
useradd -g node_exporter --no-create-home --shell /bin/false node_exporter

cd /tmp
curl -sL https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-arm64.tar.gz | tar xz
cp /tmp/node_exporter-1.7.0.linux-arm64/node_exporter /usr/bin/
chmod +x /usr/bin/node_exporter
chown node_exporter:node_exporter /usr/bin/node_exporter

echo "[Unit]
Description=Node Exporter
Documentation=https://prometheus.io/docs/guides/node-exporter/
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
Restart=on-failure
ExecStart=/usr/bin/node_exporter \
--web.listen-address=:9200
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/node_exporter.service

systemctl daemon-reload
systemctl enable node_exporter.service
systemctl start node_exporter.service

echo "node_exporter installation done!"
}

node_exporter

0 comments on commit c120a52

Please sign in to comment.