Tena ra, e nga tangata o Habr!
I tenei ra e hiahia ana ahau ki te korero ki a koe me pehea ta matou hiahia ki te aro turuki i nga pou me etahi atu hinonga e rua i roto i te roopu OpenShift me pehea ta matou mahi.
I te tomokanga i a ratou:
- Huringa tuwhera
- Helm
- Prometheus
Hei mahi me te tono java, he maamaa noa nga mea katoa, he maamaa, he tika ake ranei:
1) Te taapiri ki te build.gradle
implementation "io.micrometer:micrometer-registry-prometheus"
2) Whakahaerehia te prometheus me te whirihoranga
- job_name: 'job-name'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- 'name'
3) Te taapiri whakaatu ki a Grafana
Ko nga mea katoa he maamaa noa, he ngawari hoki tae noa ki te waa ki te tirotiro i nga turanga e tu tata ana ki to maatau ingoa ingoa (ae, he kino tenei, kaore tetahi e mahi, engari he rereke nga mea ka puta).
Pehea te mahi?
I tua atu i te peera me nga postgres me te prometheus ake, me kotahi ano te hinonga - he kaihoko.
Ko te kaihoko i roto i te ariā waitara he kaihoko e kohi inenga mai i tetahi tono, i tetahi tūmau ranei. Mo te kaikawe postgres, kua tuhia ki roto i te Haere, e mahi ana i runga i te kaupapa o te whakahaere i nga tuhinga SQL i roto i te paataka raraunga katahi ka tango a prometheus i nga hua kua puta. Ma tenei ka taea e koe te whakawhānui ake i nga inenga kua kohia ma te taapiri i a koe ake.
Me whakatakoto penei (hei tauira deployment.yaml, kore-herea):
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: postgres-exporter
labels:
app: {{ .Values.name }}
monitoring: prometheus
spec:
serviceName: {{ .Values.name }}
replicas: 1
revisionHistoryLimit: 5
template:
metadata:
labels:
app: postgres-exporter
monitoring: prometheus
spec:
containers:
- env:
- name: DATA_SOURCE_URI
value: postgresdb:5432/pstgr?sslmode=disable
- name: DATA_SOURCE_USER
value: postgres
- name: DATA_SOURCE_PASS
value: postgres
resources:
limits:
cpu: 100m
memory: 50Mi
requests:
cpu: 100m
memory: 50Mi
livenessProbe:
tcpSocket:
port: metrics
initialDelaySeconds: 30
periodSeconds: 30
readinessProbe:
tcpSocket:
port: metrics
initialDelaySeconds: 10
periodSeconds: 30
image: exporter
name: postgres-exporter
ports:
- containerPort: 9187
name: metrics
I hiahiatia ano he ratonga me te rerenga whakaahua
Whai muri i te tukunga, ka tino hiahia matou kia kite nga tangata katoa.
Tāpirihia te waahanga e whai ake nei ki te whirihora Prometheus:
- job_name: 'postgres_exporter'
metrics_path: '/metrics'
scrape_interval: 5s
dns_sd_configs:
- names:
- 'postgres-exporter'
type: 'A'
port: 9187
Na ka mahi nga mea katoa, ko te toenga ko te taapiri i enei mea katoa ki te grafana ka pai ki te hua.
I tua atu i te kaha ki te taapiri i a koe ake patai, ka taea e koe te whakarereke i nga tautuhinga i roto i te prometheus, me te kohikohi i nga inenga kua whakaritea.
He rite tonu tenei mahi mo:
- Kafka
- Te rangahau elastic
- Mongo
PS Ko nga raraunga katoa mo nga ingoa, nga tauranga me era atu ka tangohia mai i te rangi kaore he korero kei roto.
Hononga whaihua:
Source: will.com