Jan 01, 1970
오래 전에는 우리가 알고 있는 관측 가능성이 존재하지 않았습니다. 대신 우리가 가진 것은 모니터링 이었습니다. 그 당시 모니터링은 대시보드가 표시된 화면을 여러 사람이 보는 일이었습니다. 대시보드 자체는 지표와 시스템 지표(주로 CPU, 메모리, 디스크 사용량)로만 구성되었습니다. 이러한 이유로 측정항목부터 시작하겠습니다.
version: "3" services: fake-metrics: build: ./fake-metrics-generator #1 collector: image: otel/opentelemetry-collector:0.87.0 #2 environment: #3 - METRICS_HOST=fake-metrics - METRICS_PORT=5000 volumes: - ./config/collector/config.yml:/etc/otelcol/config.yaml:ro #4
receivers: #1 prometheus: #2 config: scrape_configs: #3 - job_name: fake-metrics #4 scrape_interval: 3s static_configs: - targets: [ "${env:METRICS_HOST}:${env:METRICS_PORT}" ] exporters: #5 logging: #6 loglevel: debug service: pipelines: #7 metrics: #8 receivers: [ "prometheus" ] #9 exporters: [ "logging" ] #9
prometheus
수신기를 사용합니다.prometheus
수신기로부터 데이터를 가져와 logging
내보내기 도구로 보냅니다. 즉 , 이를 인쇄합니다.
2024-11-11 08:28:54 otel-collector-collector-1 | StartTimestamp: 1971-01-01 00:00:00 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Timestamp: 2024-11-11 07:28:54.14 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Value: 83.090000 2024-11-11 08:28:54 otel-collector-collector-1 | NumberDataPoints #1 2024-11-11 08:28:54 otel-collector-collector-1 | Data point attributes: 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__embrace_world_class_systems: Str(concept) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__exploit_magnetic_applications: Str(concept) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__facilitate_wireless_architectures: Str(extranet) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__grow_magnetic_communities: Str(challenge) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__reinvent_revolutionary_applications: Str(support) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__strategize_strategic_initiatives: Str(internet_solution) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__target_customized_eyeballs: Str(concept) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__transform_turn_key_technologies: Str(framework) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__whiteboard_innovative_partnerships: Str(matrices) 2024-11-11 08:28:54 otel-collector-collector-1 | StartTimestamp: 1971-01-01 00:00:00 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Timestamp: 2024-11-11 07:28:54.14 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Value: 53.090000 2024-11-11 08:28:54 otel-collector-collector-1 | NumberDataPoints #2 2024-11-11 08:28:54 otel-collector-collector-1 | Data point attributes: 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__expedite_distributed_partnerships: Str(approach) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__facilitate_wireless_architectures: Str(graphical_user_interface) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__grow_magnetic_communities: Str(policy) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__reinvent_revolutionary_applications: Str(algorithm) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__transform_turn_key_technologies: Str(framework) 2024-11-11 08:28:54 otel-collector-collector-1 | StartTimestamp: 1971-01-01 00:00:00 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Timestamp: 2024-11-11 07:28:54.14 +0000 UTC 2024-11-11 08:28:54 otel-collector-collector-1 | Value: 16.440000 2024-11-11 08:28:54 otel-collector-collector-1 | NumberDataPoints #3 2024-11-11 08:28:54 otel-collector-collector-1 | Data point attributes: 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__exploit_magnetic_applications: Str(concept) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__grow_magnetic_communities: Str(graphical_user_interface) 2024-11-11 08:28:54 otel-collector-collector-1 | -> fake__target_customized_eyeballs: Str(extranet)
exporters: prometheus: #1 endpoint: ":${env:PROMETHEUS_PORT}" #2 service: pipelines: metrics: receivers: [ "prometheus" ] exporters: [ "prometheus" ] #3
prometheus
내보내기 추가
exporters: prometheus: #1 endpoint: ":${env:PROMETHEUS_PORT}" logging: #2 loglevel: debug service: pipelines: metrics: receivers: [ "prometheus" ] exporters: [ "prometheus", "logging" ] #3
수신자와 수출자는 자신의 유형을 지정 하며 각각은 고유해야 합니다. 마지막 요구 사항을 준수하기 위해 prometheus/foo
및 prometheus/bar.
를 구별하는 한정자를 추가할 수 있습니다 .
구성 파일의 processors
섹션에서 데이터 프로세서를 선언합니다. 컬렉터는 선언된 순서대로 실행합니다. 위의 변환을 구현해 보겠습니다.
collector: image: otel/opentelemetry-collector-contrib:0.87.0 #1 environment: - METRICS_HOST=fake-metrics - METRICS_PORT=5000 - PROMETHEUS_PORT=8889 volumes: - ./config/collector/config.yml:/etc/otelcol-contrib/config.yaml:ro #2
contrib
플레이버를 사용하세요
processors: metricstransform: #1 transforms: #2 - include: ^fake_(.*)$ #3 match_type: regexp #3 action: update operations: #4 - action: add_label #5 new_label: origin new_value: fake - include: ^fake_(.*)$ match_type: regexp action: update #6 new_name: $${1} #6-7 # Do the same with metrics generated by NodeJS
$${x}
입니다.
service: pipelines: metrics: receivers: [ "prometheus" ] processors: [ "metricstransform" ] exporters: [ "prometheus" ]
커넥터는 수신자이자 내보내기 이며 두 파이프라인을 연결합니다. 문서의 예는 범위 수(추적)를 수신하고 측정항목이 있는 개수를 내보냅니다. 나는 500개의 오류로 동일한 결과를 얻으려고 노력했습니다. 스포일러: 의도한 대로 작동하지 않습니다.
receivers: filelog: include: [ "/var/logs/generated.log" ]
connectors: count: requests.errors: description: Number of 500 errors condition: [ "status == 500 " ]
service: pipelines: logs: receivers: [ "filelog" ] exporters: [ "count" ] metrics: receivers: [ "prometheus", "count" ]
측정항목 이름은 log_record_count_total
이지만 값은 1로 유지됩니다.
receivers: filelog: include: [ "/var/logs/generated.log" ] operators: - type: json_parser #1 timestamp: #2 parse_from: attributes.datetime #3 layout: "%d/%b/%Y:%H:%M:%S %z" #4 severity: #2 parse_from: attributes.status #3 mapping: #5 error: 5xx #6 warn: 4xx info: 3xx debug: 2xx - id: remove_body #7 type: remove field: body - id: remove_datetime #7 type: remove field: attributes.datetime - id: remove_status #7 type: remove field: attributes.status
501-599
. 연산자에는 HTTP 상태에 대해 특수하게 해석된 값 5xx
(및 유사)가 있습니다.
exporters: loki: endpoint: "//loki:3100/loki/api/v1/push"
service: telemetry: logs:
service: pipelines: logs: receivers: [ "filelog" ] exporters: [ "loki" ]
더 나아가려면:
원래 2023년 11월 12일 에 .