Prometheus 서비스 검색 메커니즘
13798 단어 prometheus
카탈로그
Prometheus 서비스 발견 메커니즘 개요
Prometheus 데이터 원본의 구성은 주로 정적 구성과 동적 발견으로 나뉘는데 주로 다음과 같은 몇 가지 유형으로 사용된다.
static_configs: 정적 서비스 발견
Prometheus.yaml 프로필:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'grafana'
static_configs:
- targets:
- 'grafana-service.ns-monitor:3000'
- job_name: 'kubernetes-apiservers'
file_sd_configs: 파일 서비스 발견
파일 기반 서비스 발견 방식은 다른 플랫폼과 제3자 서비스에 의존할 필요가 없다. 사용자는 새로운 target 정보를 yaml이나 json 파일 형식으로 target 파일에 추가하기만 하면 prometheus는 정기적으로 지정된 파일에서 target 정보를 읽고 업데이트한다.
target 파일:
vim targets.json
[
{
"targets": [ "192.168.20.136:9100"],
"labels": {
"instance": "nodeone",
"job": "expor_test1"
}
},
{
"targets": [ "192.168.20.137:9100"],
"labels": {
"instance": "nodetwo",
"job": "expor_test2"
}
}
]
Prometheus.yaml 프로필:
scrape_configs:
- job_name: 'file_sd' #
file_sd_configs:
- files:
- targets.json #
웹 인터페이스 targets 보기 targets.json이 정의한 두 개의 job.
dns_sd_configs: DNS 서비스 검색
등한시하다
kubernetes_sd_configs: Kubernetes 서비스 발견
kubernetes의 경우,Promethues는 Kubernetes API와 상호작용을 한 다음에 자원 단점을 윤문한다.현재 주로 5가지 서비스 발견 모델을 지원하는데 그것이 1:Node, 2:서비스, 3:Pod, 4:Endpoints, 5:Ingress 대응 설정 파일의 Role:node/role:서비스이다.
모든 노드 node에 대한 정보를 동적으로 가져오며 다음 구성을 추가할 수 있습니다.
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}/proxy/metrics
- job_name: 'kubernetes-service-endpoints'
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: kubernetes_name
대응하는 서비스,pod도 같은 방식이다.주의해야 할 것은 Prometheus가 Kubernetes API를 받을 수 있도록 하기 위해서, 우리는 Prometheus에 대한 접근 권한을 부여해야 한다. 즉 서비스account이다.그렇지 않으면 설정되어 있어도 가져올 권한이 없습니다.
Prometheus의 relabelconfigs 구성 세부 정보:
consul_sd_configs: Consul 서비스 검색
설명
Consul은 GO 언어를 바탕으로 개발한 소스 오픈 도구로 주로 분포식, 서비스화된 시스템을 대상으로 서비스 등록, 서비스 발견과 설정 관리 기능을 제공한다.Consul은 서비스 등록/검색, 건강 검사, Key/Value 저장소, 다중 데이터 센터와 분포식 일치성 보증 등의 기능을 제공합니다.이전에는 Prometheus를 통해 Target가 추가되었을 때 file 을 사용해도 서버의 프로필을 변경해야 한다는 모니터링을 실현했습니다.sd_configs 설정도 서버에 로그인해서 Json 파일을 수정해야 하기 때문에 매우 번거롭습니다.
Consul 설치 구성
대략
prometheus.yml 구성:
- job_name: 'consul-prometheus'
consul_sd_configs:
- server: '172.30.12.167:8500'
services: []
설명: 여기는 consul 을 사용해야 합니다sd_configs는 Consul 서비스 발견 형식을 사용하고 서버가 Consul인 서비스 주소를 설정합니다.구성이 완료되면 Prometheus 서비스를 다시 시작합니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Rancher Preview 2.3.0-alpha5 Istio kiali Jaeger Promethesu+GrafanaRancher2.3 Preview로서, Istio kiali Jaeger 그리고 2.2에서 동봉된 Prometheus+Grafana와는 별도로 기능으로서 추가되었습니다. Bookinfo 애플리케이션을 기반으로 시도해...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.