Last active
January 8, 2022 15:52
-
-
Save ruzickap/6efa3913deb73f3b4f0afb1da7623bb2 to your computer and use it in GitHub Desktop.
Few commands to configure Grafana Agent to allow sending data to Grafana Cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install blackbox-exporter | |
apt update | |
apt install -y prometheus-blackbox-exporter | |
# Chnage the garfana agent config file /etc/grafana-agent.yaml | |
cat > /etc/grafana-agent.yaml << EOF | |
integrations: | |
agent: | |
enabled: true | |
process_exporter: | |
enabled: true | |
process_names: | |
- comm: | |
- grafana-agent | |
- prometheus-blac | |
- systemd | |
node_exporter: | |
enabled: true | |
enable_collectors: | |
- interrupts | |
- meminfo_numa | |
- mountstats | |
- systemd | |
- tcpstat | |
prometheus_remote_write: | |
- basic_auth: | |
password: eyxxxxxxxxxxxxxxxF9 | |
username: 2xxxxxx2 | |
url: https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push | |
loki: | |
configs: | |
- clients: | |
- basic_auth: | |
password: eyxxxxxxxxxxxxxxxF9 | |
username: 1yyyyyyyy6 | |
url: https://logs-prod-eu-west-0.grafana.net/api/prom/push | |
name: integrations | |
positions: | |
filename: /tmp/positions.yaml | |
target_config: | |
sync_period: 10s | |
scrape_configs: | |
- job_name: system | |
static_configs: | |
- labels: | |
__path__: /var/log/{*log,daemon,messages} | |
job: varlogs | |
targets: | |
- localhost | |
prometheus: | |
configs: | |
- name: agent | |
scrape_configs: | |
- job_name: grafana-agent | |
static_configs: | |
- targets: ['127.0.0.1:12345'] | |
- job_name: blackbox-http_2xx | |
metrics_path: /probe | |
params: | |
module: [http_2xx] | |
static_configs: | |
- targets: | |
- http://192.168.1.1 | |
- https://google.com | |
- https://root.cz | |
relabel_configs: | |
- source_labels: [__address__] | |
target_label: __param_target | |
- source_labels: [__param_target] | |
target_label: instance | |
- target_label: __address__ | |
replacement: 127.0.0.1:9115 | |
- job_name: blackbox-icmp | |
metrics_path: /probe | |
params: | |
module: [icmp] | |
scrape_interval: 5s | |
static_configs: | |
- targets: | |
- 192.168.1.1 | |
- google.com | |
- root.cz | |
relabel_configs: | |
- source_labels: [__address__] | |
target_label: __param_target | |
- source_labels: [__param_target] | |
target_label: instance | |
- target_label: __address__ | |
replacement: 127.0.0.1:9115 | |
remote_write: | |
- basic_auth: | |
password: eyxxxxxxxxxxxxxxxF9 | |
username: 2xxxxxx2 | |
url: https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push | |
global: | |
scrape_interval: 60s | |
wal_directory: /tmp/grafana-agent-wal | |
server: | |
http_listen_port: 12345 | |
EOF | |
# Chnage the garfana agent config file /etc/prometheus/blackbox.yml and add preferred protocol | |
cat > /etc/prometheus/blackbox.yml << EOF | |
modules: | |
http_2xx: | |
prober: http | |
http: | |
preferred_ip_protocol: ip4 | |
tcp_connect: | |
prober: tcp | |
tcp: | |
preferred_ip_protocol: ip4 | |
icmp: | |
prober: icmp | |
icmp: | |
preferred_ip_protocol: ip4 | |
EOF | |
systemctl restart prometheus-blackbox-exporter grafana-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment