Prometheus push gateway is a method for gathering metrics that is extremely resilient is provided by the Prometheus pull model. However, there are some situations in which this model does not work well. As a middleman, Prometheus Pushgateway offers a push-based method for gathering metrics without compromising the server’s simplicity. You will have the opportunity to set up and install your own Prometheus Pushgateway instance in this lab. You’ll get some hands-on experience with setting up Pushgateway as a result of this.
In this post, We will install and configure the prometheus pushgateway on ubuntu 22.04 LTS server.
Step 1: Create System user for Push-Gateway
We need to execute the follwing command to create a system user in ubuntu machine.
sudo useradd -M -r -s /bin/false pushgateway
Step 2: Download the Push gateway binary file
We need to download the push gateway binary file from prometheus download page , We need to execute the given command one by one.
To change the directory.
To download the push gateway binary.
To extract the tar file.
tar xvfz pushgateway-*.linux-amd64.tar.gz
To make copy of push gateway binary file in ubuntu os binary location path.
sudo cp pushgateway-*.linux-amd64/pushgateway /usr/local/bin/
To update the right permission with ownership.
sudo chown pushgateway:pushgateway /usr/local/bin/pushgateway
Step 3: Create SystemD Service
In this step, We need to create a systemd service to control the push gateway daemon using
Use nano editor with given location in order to create systemD config file.
sudo nano /etc/systemd/system/pushgateway.service
Paste the follwing code in your file.
[Unit] Description=Prometheus Pushgateway Wants=network-online.target After=network-online.target [Service] User=pushgateway Group=pushgateway Type=simple ExecStart=/usr/local/bin/pushgateway [Install] WantedBy=multi-user.target
Its time to reload the daemon 1st, To get new changes in systemD.
sudo systemctl daemon-reload
this is good pratice to enable push gateway service on boot.
sudo systemctl enable pushgateway
This commad start the push gateway service on ubuntu machine, by default its works on port 9091.
sudo systemctl start pushgateway
To validate the push gateway up and running.
sudo systemctl status pushgateway
Step 4: Verify Metrics End-ponits
We need to also test the push gateway exposing the metircs on port 9091 or not, To make sure we need to open the port 9091 and execute the given command.
Step 5: Configure Push gateway with Prometheus server
Once the push gateway metrics are working fine, So then We are good to configure push gateway end-poits with promtheus server to pull the metrics from push gateway.
Execute the given command to open the prometheus main configuration file.
sudo nano /etc/prometheus/prometheus.yml
In scarping section, You must update the push gateway ip and port here, and the job name and its properties must be added, as shown in the example configuration.
- job_name: 'Pushgateway' honor_labels: true static_configs: - targets: ['TYPE_PUSH-GATEWAY_IP_HERE:9091']
To get new chnages in prometheus we need to restart the prometheus service once.
sudo systemctl restart prometheus
Also this is a good pratice to check prometeus service status.
sudo systemctl status prometheus
Verify that Prometheus allows you to view Pushgateway metrics by using expression browser. Expression Browser can be accessed through a web browser at
http://YOUR_PROMETHEUS_IP:9090 and execute a query to view some Pushgateway metric data:
We have successfully installed prometheus push gateway server on ubuntu 22.04 LTS, If you still have questions, please post them in the comments section below.
2 thoughts on “Installing Prometheus Pushgateway on Ubuntu 22.04 LTS”
Can you write more about it? Your articles are always helpful to me. Thank you!