Skip to content

Instantly share code, notes, and snippets.

@vikram-raj
Created October 2, 2020 09:48
Show Gist options
  • Save vikram-raj/d801e9ef6400cc1bd5af5a336bbedfa0 to your computer and use it in GitHub Desktop.
Save vikram-raj/d801e9ef6400cc1bd5af5a336bbedfa0 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Namespace
metadata:
name: ns1
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: prometheus-example-app
name: prometheus-example-app
namespace: ns1
spec:
replicas: 1
selector:
matchLabels:
app: prometheus-example-app
template:
metadata:
labels:
app: prometheus-example-app
spec:
containers:
- image: quay.io/brancz/prometheus-example-app:v0.1.0
imagePullPolicy: IfNotPresent
name: prometheus-example-app
---
apiVersion: v1
kind: Service
metadata:
labels:
app: prometheus-example-app
name: prometheus-example-app
namespace: ns1
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
name: web
selector:
app: prometheus-example-app
type: ClusterIP
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: prometheus-example-monitor
name: prometheus-example-monitor
namespace: ns1
spec:
endpoints:
- interval: 30s
port: web
scheme: http
selector:
matchLabels:
app: prometheus-example-app
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: example-alert
namespace: ns1
spec:
groups:
- name: example
rules:
- record: CriticalAlert
expr: version{job="prometheus-example-app"}
- alert: CriticalAlert
expr: version{job="prometheus-example-app"} == 0
for: 1s
labels:
severity: critical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment