Prometheus Pushgateway: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 54: | Line 54: | ||
targetPort: 9091 | targetPort: 9091 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Expose it then as a target with a [[Prometheus_Operator_Concepts#ServiceMonitor_Resource|ServiceMonitor]]: | Expose it then as a Prometheus scraping [[Prometheus_Concepts#Target|target]] with a [[Prometheus_Operator_Concepts#ServiceMonitor_Resource|ServiceMonitor]]: | ||
<syntaxhighlight lang='yaml'> | <syntaxhighlight lang='yaml'> | ||
apiVersion: monitoring.coreos.com/v1 | apiVersion: monitoring.coreos.com/v1 |
Revision as of 23:26, 14 October 2020
External
- https://prometheus.io/docs/instrumenting/pushing/
- https://github.com/prometheus/pushgateway/blob/master/README.md
- https://www.metricfire.com/blog/prometheus-pushgateways-everything-you-need-to-know/
Internal
Overview
Push gateways are used in case of applications or short-lived jobs that do not export metrics directly.
Installation
Kubernetes
Deploy the pod and associated services:
apiVersion: v1
kind: Pod
metadata:
name: 'pushgateway'
labels:
function: 'pushgateway'
spec:
containers:
- name: 'pushgateway'
image: prom/pushgateway
---
apiVersion: v1
kind: Service
metadata:
name: 'pushgateway'
labels:
function: 'prometheus-target'
spec:
type: 'ClusterIP'
selector:
function: 'pushgateway'
ports:
- name: 'pushgateway'
protocol: 'TCP'
port: 9091
targetPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: 'pushgateway-lb'
spec:
type: 'LoadBalancer'
selector:
function: 'pushgateway'
ports:
- name: 'pushgateway'
protocol: 'TCP'
port: 9091
targetPort: 9091
Expose it then as a Prometheus scraping target with a ServiceMonitor:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: pushgateway
namespace: prometheus
labels:
release: prometheus
spec:
endpoints:
- path: /metrics
port: "9091"
namespaceSelector:
matchNames:
- prometheus
selector:
matchLabels:
function: pushgateway-target
Playground
Operations
Push a Metric Sample
echo "some_metric 3.14" | curl --data-binary @- http://localhost:9091/metrics/job/some_job
Console
Query Metrics
Do not use trailing slash otherwise you'll get "Moved Permanently":
curl http://localhost:9091/metrics
Query Health
curl http://localhost:9091/-/healthy
Query Readiness
curl http://localhost:9091/-/ready