콘텐츠로 이동

Consul

·


Consul 수집기는 Consul 관련 메트릭 데이터를 수집하는 데 사용됩니다. 현재는 Prometheus 형식의 데이터만 지원합니다.

설정

사전 조건

consul-exporter 설치

  • consul_exporter 압축 패키지 다운로드
sudo wget https://github.com/prometheus/consul_exporter/releases/download/v0.7.1/consul_exporter-0.7.1.linux-amd64.tar.gz
  • consul_exporter 압축 패키지의 압축을 풉니다.
sudo tar -zxvf consul_exporter-0.7.1.linux-amd64.tar.gz  
  • consul_exporter-0.7.1.linux-amd64 디렉토리를 입력하고 consul_exporter 스크립트를 실행하십시오.
./consul_exporter     

수집기 설정

DataKit 설치 디렉토리 아래에 conf.d/samples 디렉토리를 입력하고 consul.conf.sample를 복사한 후 이름을 consul.conf로 지정합니다. 예는 다음과 같습니다:

[[inputs.prom]]
  url = "http://127.0.0.1:9107/metrics"
  source = "consul"
  metric_types = ["counter", "gauge"]
  metric_name_filter = ["consul_raft_leader", "consul_raft_peers", "consul_serf_lan_members", "consul_catalog_service", "consul_catalog_service_node_healthy", "consul_health_node_status", "consul_serf_lan_member_status"]
  measurement_prefix = ""
  tags_ignore = ["check"]
  interval = "10s"

[[inputs.prom.measurements]]
  prefix = "consul_"
  name = "consul"

구성 후 DataKit 다시 시작만 사용하면 됩니다.

현재 수집기 구성을 삽입하는 ConfigMap 메서드를 통해 컬렉터를 켤 수 있습니다.

메트릭

consul

Tags & Fields Description
check
(tag)
Consul health check label emitted by consul_exporter.
check_id
(tag)
Consul health check ID.
check_name
(tag)
Consul health check name.
host
(tag)
Host name associated with the scraped Consul exporter target.
instance
(tag)
Scraped exporter instance endpoint.
key
(tag)
Consul KV key.
member
(tag)
Consul Serf member name.
node
(tag)
Consul node name.
service_id
(tag)
Consul service ID.
service_name
(tag)
Consul service name.
status
(tag)
Consul health status label, such as critical, maintenance, passing, or warning.
tag
(tag)
Consul service tag value.
catalog_kv Numeric value stored at the tagged Consul key in the key/value catalog. Non-numeric keys are omitted.
Type: float | (gauge)
Unit: N/A
catalog_service_node_healthy Whether the tagged Consul service is healthy on the tagged node.
Type: float | (gauge)
Unit: bool
catalog_services Number of services registered in the Consul catalog.
Type: float | (gauge)
Unit: count
health_node_status Whether the tagged Consul node health check is currently in the tagged status.
Type: float | (gauge)
Unit: bool
health_service_status Whether the tagged Consul service health check is currently in the tagged status.
Type: float | (gauge)
Unit: bool
raft_leader Whether this Consul node reports that the Raft cluster currently has a leader.
Type: float | (gauge)
Unit: bool
raft_peers Number of Consul servers participating as peers in the Raft cluster.
Type: float | (gauge)
Unit: count
serf_lan_member_status Numeric Serf LAN member status code for the tagged member. 1=alive, 2=leaving, 3=left, 4=failed.
Type: float | (gauge)
Unit: N/A
serf_lan_members Number of members in the Consul Serf LAN pool.
Type: float | (gauge)
Unit: count
serf_wan_member_status Numeric Serf WAN member status code for the tagged member. 1=alive, 2=leaving, 3=left, 4=failed.
Type: float | (gauge)
Unit: N/A
service_checks Whether the tagged Consul service is linked with the tagged check_id and check_name.
Type: float | (gauge)
Unit: bool
service_tag Whether the tagged Consul service tag exists for the service_id, node, and tag label set.
Type: float | (gauge)
Unit: bool
up Whether the consul_exporter successfully queried Consul during the last scrape.
Type: float | (gauge)
Unit: bool

로그

Consul 로그를 수집하려면 Consul을 열 때 -syslog 매개변수를 사용해야 합니다. 예를 들어

consul agent -dev -syslog

로깅 수집기를 사용하여 로그를 수집하려면 로깅 수집기를 구성해야 합니다. DataKit 설치 디렉토리 아래에 conf.d/log 디렉토리를 입력하고 logging.conf.sample를 복사한 후 이름을 logging.conf로 지정합니다. 구성은 다음과 같습니다.

[[inputs.logging]]
  ## required
  logfiles = [
    "/var/log/syslog",
  ]

  ## glob filteer
  ignore = [""]

  ## your logging source, if it's empty, use 'default'
  source = "consul"

  ## add service tag, if it's empty, use $source.
  service = ""

  ## grok pipeline script path
  pipeline = "consul.p"

  ## optional status:
  ##   "emerg","alert","critical","error","warning","info","debug","OK"
  ignore_status = []

  ## optional encodings:
  ##    "utf-8", "utf-16le", "utf-16le", "gbk", "gb18030" or ""
  character_encoding = ""

  ## The pattern should be a regexp. Note the use of '''this regexp'''
  ## regexp link: https://golang.org/pkg/regexp/syntax/#hdr-Syntax
  multiline_match = '''^\S'''

  [inputs.logging.tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"

원본 로그 텍스트:

Sep 18 19:30:23 derrick-ThinkPad-X230 consul[11803]: 2021-09-18T19:30:23.522+0800 [INFO]  agent.server.connect: initialized primary datacenter CA with provider: provider=consul

파싱 후 필드 목록은 다음과 같습니다.

필드 이름 필드 값 설명
date 2021-09-18T19:30:23.522+0800 로그 날짜
level INFO 로그 수준
character agent.server.connect 역할
msg initialized primary datacenter CA with provider: provider=consul 로그 내용

문서 평가

이 페이지가 도움이 되었나요?