What is Pushgateway?

What is Pushgateway?

Table of Contents

Introduction

Prometheus is an amazing tool, but it has limitations. Some of your applications, including batch jobs and ephemeral jobs, may not live long enough for it to find and scrape them.

                            

Since Prometheus cannot scrape all jobs, the company developed Pushgateway as a bridge tool. Because you usually cannot push metrics directly to the Prometheus application, you can sometimes use a Pushgateway to deliver the necessary data. 

                          

When you need monitoring solutions, try Metricfire. You’ll learn about the best open-source applications around. Visit the website today for a free trial and demo.

        

        

Key Takeaways

  1. Prometheus limitations: Prometheus struggles with scraping metrics from short-lived applications like batch jobs and ephemeral jobs.
  2. Introduction to Pushgateway: Pushgateway acts as a bridge tool, allowing these short-lived jobs to push their metrics to a cache that Prometheus can access.
  3. Use cases and limitations: Pushgateway is suitable for service-level batch jobs but not all short-lived jobs. Node exporter is recommended for jobs tied to long-living subjects.
  4. Pushgateway functionality: Pushgateway enables metric sending, scraping, deletion, and alerts, but has some consistency issues with metric exposure.

 

What is Pushgateway?

Pushgateway is a feature of Prometheus that allows ephemeral and batch jobs to expose their metrics to the application. Often, these types of jobs do not have a long enough lifecycle for software programs to scrape them and pull the vast amount of metrics necessary for effective network monitoring.

                

Instead, you can push your metrics to a Pushgateway that, in turn, exposes the metrics to Prometheus. Consider Pushgateway the middleman in metrics collection. You can push your short-lived batch and ephemeral jobs onto Pushgateway, using it as a metrics cache that then allows Prometheus to scrape them, even when the monitored subjects no longer exist.

          

This process differs from Prometheus' pull metrics application. With Pushgateway, your metrics series is continually exposed to Prometheus unless someone manually deletes it using Pushgateway's API. When Prometheus uses pull model metrics, it only has access to those instances that still exist. This application has client libraries for Go, Java, Scala, Python, and Ruby, making it useful for a wide audience.

         

        

               

What Are the Use-Cases of Pushgateway?

Pushgateway is not the answer for all your short-lifecycle jobs. Prometheus warns users that Pushgateway only works well in specific circumstances, particularly for service-level batch jobs such as deleting users' data that have requested to be deleted (the right to be forgotten).

               

Jobs that delete temporary files are not serviced batch jobs because they are tied to a long-living subject - the machine they run on. Exposing metrics for those jobs is best done by a node exporter or another method. 

          

For the node exporter, use:

           

tar -xzvf node_exporter-*.*.tar.gz cd node_exporter-*.* # Start 3 example targets in separate terminals: ./node_exporter --web.listen-address 127.0.0.1:8080 ./node_exporter --web.listen-address 127.0.0.1:8081 ./node_exporter --web.listen-address 127.0.0.1:8082

            

Reminder: the file pattern can be a path ending in j.son, yaml and yml.

      

Curious about how MetricFire can help? Sign up for a free trial and demo and learn firsthand how we can benefit your business by providing sophisticated monitoring help.

          

Pushgateway Benefits and Challenges

Prometheus offers alternative strategies for when an inbound firewall or NAT prevents you from pulling metrics. For instance, you can move the Prometheus server behind the network barrier. Pushgateway is a valuable tool that is effective in limited situations. You cannot use it for all jobs whose metrics Prometheus cannot scrape. You can perform the following tasks with a Pushgateway:

          

  • Send metrics - Through a program that can perform web requests or by using a client library.
  • Scrape metrics - Often by statistically defining a Pushgateway target with scrape-configs.
  • Delete metrics - By clicking near the group of metrics in the UI, By the wipe end-point on the admin API, and by making an HTTP request with the verb DELETE.
  • Alert on metrics - informing you when someone tries to push inconsistent metrics, the Pushgateway has been pushing metrics in the expected timeframe, and when there is a Pushgateway shutdown.

         

Although Pushgateway has some consistency issues, exposing all pushed metrics together with its own metrics by using the same /metrics endpoint, it can save your metrics to disk for a defined time period by using the parameters "persistence.file= and --persistence.interval=. 

      

You will need to have some mounted-storage writable by one now to serve the traffic and the other that have persistent storage mounted as read-only. For those using Kubernetes, you can manage this task with a persistent volume claim with the mode ReadWriteOnce. You do have several options for making Pushgateway your metrics cache.

         

Pushgateway Metrics

By using the configured --web.telemetry-path (default: /metrics, you will expose the following metrics: 

              

  • Pushed metrics
  • Metric push-time-seconds and push-failure-time-second
  • Metrics provided by Prometheus Go client library
  • Specific metrics for Pushgateway such as # HELP pushgateway_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pushgateway was built, and # TYPE pushgateway_build_info gauge.

       

Although this application has a very specific purpose, it can be an invaluable tool for a wide range of companies. To get started, just download the latest version of Prometheus and then extract it and run it using tar xvfz prometheus-*.tar.gz cd prometheus-*

       

       

How Can MetricFire Help?

Pushing metrics through this application can solve your metrics exposure problem with minimum effort. Their team can also help you with Pushgateway authentication, Prometheus static-configs, job labels and other factors that can make metric exposure challenging. You will have access to hosted Graphite monitoring and Grafana dashboards.

           

Reach out to us today for a MetricFire free trial and demo to see how we can meet your metric gathering needs.

You might also like other posts...
metricfire Apr 10, 2024 · 9 min read

Step-by-Step Guide to Monitoring Your SNMP Devices With Telegraf

Monitoring SNMP devices is crucial for maintaining network health and security, enabling early detection... Continue Reading

metricfire Mar 13, 2024 · 8 min read

Easy Guide to monitoring uWSGI Using Telegraf and MetricFire

It's important to monitor uWSGI instances to ensure their stability, performance, and availability, helping... Continue Reading

metricfire Mar 12, 2024 · 8 min read

How to Monitor ClickHouse With Telegraf and MetricFire

Monitoring your ClickHouse database is a proactive measure that helps maintain its health and... Continue Reading

header image

We strive for
99.999% uptime

Because our system is your system.

14-day trial 14-day trial
No Credit Card Required No Credit Card Required