AVM Consulting Blog

AVM Consulting — Clear strategy for your cloud

Follow publication

Member-only story

Scrape data using Bash script and push it to Prometheus using PushGateway

--

As you may be aware that prometheus is a pull based metrics server which scraps data from the specified scrap endpoints. But we can also push data to Prometheus using PushGateway. In this post we’ll see how we can push data fetched by our shell script, to Prometheus.

Pre-requisite: Ubuntu 16.04 machine with 9090(Prometheus) and 3000(Grafana)ports opened.

Step 1: Install Prometheus by executing following commands:

sudo useradd -M -r -s /bin/false prometheus
sudo mkdir /etc/prometheus /var/lib/prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.20.0/prometheus-2.20.0.linux-amd64.tar.gztar xzf prometheus-2.20.0.linux-amd64.tar.gz prometheus-2.20.0.linux-amd64/


sudo cp prometheus-2.20.0.linux-amd64/{prometheus,promtool} /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/{prometheus,promtool}
sudo cp -r prometheus-2.20.0.linux-amd64/{consoles,console_libraries} /etc/prometheus/
sudo cp prometheus-2.20.0.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus

Now create a systemd unit file for Prometheus by creating a file named /etc/systemd/system/prometheus.service with following content:

[Unit]
Description=Prometheus Time Series Collection and Processing Server
Wants=network-online.target…

--

--

AVM Consulting Blog
AVM Consulting Blog

Published in AVM Consulting Blog

AVM Consulting — Clear strategy for your cloud

Vinayak Pandey
Vinayak Pandey

Written by Vinayak Pandey

Experienced Cloud Engineer with a knack of automation. Linkedin profile: https://www.linkedin.com/in/vinayakpandeyit/

Responses (2)

Write a response