The Linux integration for Grafana Cloud enables us to collect metrics related to the operating system running on a node/server. Including aspects like CPU usage, load average, memory usage, and disk and networking I/O using the well-known node_exporter. It also allows you to use the agent to scrape logs with promtail. Supported files are syslog, auth.log, kern.log and journal logs. This article will help us to add linux for grafana cloud.
This integration includes sixteen useful alerts and two pre-built dashboards to help monitor and visualize Linux metrics and logs.
In Article before, how to create account in grafana cloud for free. And now how to integrate linux.
Part 1: Install Linux Server Integration for Grafana Cloud
To integrate linux server for grafana cloud please follow this step.
- In your Grafana instance, click Home > Connections > Connect data.
- Navigate to the Linux Server tile and review the prerequisites. Then click Install integration.
- Once the integration is installed, follow the steps on the Configuration Details page to setup Grafana Agent and start sending Linux Server metrics to your Grafana Cloud instance.
- Copy code In box “Run this command to install …”, and then paste in our linux server.
- Configure integrations. Set hostname and then modify file yaml in our linux server. Please attention, insert the code below integration. File grafana agent in
/etc/grafana-agent.yaml
.
Part 2: Modify Grafana Agent yaml
In our /etc/grafana-agent.yaml
like this.
integrations:
<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-amber-color"> <strong>node_exporter:
enabled: true
relabel_configs:
- replacement: mail.habibza.in
target_label: instance</strong></mark>
agent:
enabled: true
relabel_configs:
- action: replace
source_labels:
- agent_hostname
target_label: instance
metric_relabel_configs:
- action: keep
regex: (prometheus_target_.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
source_labels:
- __name__
prometheus_remote_write:
- basic_auth:
password: glc_eyJvIjoiODI4NjA5IiwibiI6Im15LWFwaS1sYWIiLCJrIjoiMHY1V3o4VTl3OUJ0WDl0OWRpMlM0aXQ0IiwibSI6eyJyIjoicHJvZC1hcC1zb3V0aGVhc3QtMCJ9fQ==
username: 925889
url: https://prometheus-prod-18-prod-ap-southeast-0.grafana.net/api/prom/push
logs:
configs:
- clients:
- basic_auth:
password: glc_eyJvIjoiODI4NjA5IiwibiI6Im15LWFwaS1sYWIiLCJrIjoiMHY1V3o4VTl3OUJ0WDl0OWRpMlM0aXQ0IiwibSI6eyJyIjoicHJvZC1hcC1zb3V0aGVhc3QtMCJ9fQ==
username: 461913
url: https://logs-prod-011.grafana.net/loki/api/v1/push
name: integrations
positions:
filename: /tmp/positions.yaml
scrape_configs:
<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-amber-color">- job_name: integrations/node_exporter_journal_scrape
journal:
max_age: 24h
labels:
instance: mail.habibza.in
job: integrations/node_exporter
relabel_configs:
- source_labels: ['__journal__systemd_unit']
target_label: 'unit'
- source_labels: ['__journal__boot_id']
target_label: 'boot_id'
- source_labels: ['__journal__transport']
target_label: 'transport'
- source_labels: ['__journal_priority_keyword']
target_label: 'level'
- job_name: integrations/node_exporter_direct_scrape
static_configs:
- targets:
- localhost
labels:
instance: mail.habibza.in
__path__: /var/log/{syslog,messages,*.log}
job: integrations/node_exporter</mark></strong>
metrics:
configs:
- name: integrations
remote_write:
- basic_auth:
password: glc_eyJvIjoiODI4NjA5IiwibiI6Im15LWFwaS1sYWIiLCJrIjoiMHY1V3o4VTl3OUJ0WDl0OWRpMlM0aXQ0IiwibSI6eyJyIjoicHJvZC1hcC1zb3V0aGVhc3QtMCJ9fQ==
username: 925889
Restart grafana agent service.
systemctl restart grafana-agent.service
Wait a moment, and we will see graphic in our grafana cloud dashboard Integrations.
NOTE: If your “instance name” not shown in list table, please check “position” and “alignment” yaml configuration in /etc/grafana-agent.yaml
.
Part 3: How to Add Second Linux Integrations and So on?
Well, we can add second, third host linux and so on. Just repeat step number 4 in in Part 1. Copy and paste the code in box and then paste in linux host. After that modify file yaml in/etc/grafana-agent.yaml
. The last restart service grafana agent.
Here is example i have two server linux. We can add again later.
Maybe usefull. Please feel free for comment.