Difference between revisions of "Pushgateway"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 17: Line 17:
 
## Using Cron job to push every 30 seconds
 
## Using Cron job to push every 30 seconds
  
/usr/local/bin/prompush
+
sudo nano /usr/local/bin/prompush
 
```
 
```
 
#!/bin/bash
 
#!/bin/bash
 
set -eu
 
set -eu
curl -s http://localhost:9100/metrics | grep -v "\(\(^\| \)go_\|http_request\|http_requests\|http_response\|process_\)" | curl --data-binary @- https://upushgateway.uvoo.io/metrics/job/c1e52efa-af1c-11ee-be01-e78fa8f1ca96-linuxnode/instance/lxd0
+
curl -s http://localhost:9100/metrics | grep -v "\(\(^\| \)go_\|http_request\|http_requests\|http_response\|process_\)" | curl --data-binary @- https://pushgateway.example.com/metrics/job/c1e52efa-af1c-11ee-be01-e78fa8f1ca96-linuxnode/instance/lxd0
 +
```
 +
 
 +
```
 +
sudo chmod +x /usr/local/bin/prompush
 
```
 
```
  

Revision as of 19:16, 9 January 2024

https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-pushgateway

https://www.metricfire.com/blog/prometheus-pushgateways-everything-you-need-to-know/

https://github.com/prometheus/pushgateway

echo "some_metric 3.14" | curl --data-binary @- https://pushgateway.example/metrics/job/some_job

As node collector

https://github.com/prometheus/node_exporter/issues/279

curl -s http://localhost:9256/metrics | grep -v "\(\(^\| \)go_\|http_request\|http_requests\|http_response\|process_\)" | curl --data-binary @- http://pushgateway.example.com:9091/metrics/job/node/instance/<INSTANCE_NAME>

Using Cron job to push every 30 seconds

sudo nano /usr/local/bin/prompush

#!/bin/bash
set -eu
curl -s http://localhost:9100/metrics | grep -v "\(\(^\| \)go_\|http_request\|http_requests\|http_response\|process_\)" | curl --data-binary @- https://pushgateway.example.com/metrics/job/c1e52efa-af1c-11ee-be01-e78fa8f1ca96-linuxnode/instance/lxd0
sudo chmod +x /usr/local/bin/prompush

/etc/cron.d/pushgateway

* * * * * nobody /usr/local/bin/prompush
* * * * * nobody sleep 30; /usr/local/bin/prompush