관측 가능성 API는 Kubernetes 커스텀 리소스를 사용하며 로깅 및 모니터링 리소스를 프로비저닝하고 관리하기 위해 Kubernetes 리소스 모델 (KRM)을 사용합니다.
관측 가능성 API를 사용하여 지정된 조직 또는 맞춤 프로젝트에서 관측 가능성 서비스의 수명 주기를 관리합니다. 관측 가능성 서비스의 수명 주기에는 설치, 업그레이드, 제거와 같은 작업이 포함됩니다. 관리하려는 Observability 서비스에 따라 커스텀 리소스를 프로젝트에 배포해야 합니다.
프로비저닝된 프로젝트에는 로깅, 모니터링, 알림과 같은 많은 관측 가능성 서비스를 자동으로 사용할 수 있습니다.
서비스 엔드포인트
다음 URL은 관측 가능성 KRM API의 API 엔드포인트입니다.
로깅 그룹:
https://MANAGEMENT_API_SERVER_ENDPOINT/apis/logging.gdc.goog/v1
모니터링 그룹:
https://MANAGEMENT_API_SERVER_ENDPOINT/apis/monitoring.gdc.goog/v1
관측 가능성 그룹:
https://MANAGEMENT_API_SERVER_ENDPOINT/apis/observability.gdc.goog/v1
MANAGEMENT_API_SERVER_ENDPOINT
를 관리 API 서버의 엔드포인트로 바꿉니다.
검색 문서
kubectl proxy --port=8001
명령어를 사용하여 로컬 머신에서 API 서버로의 프록시를 엽니다. 여기에서 다음 URL 중 하나를 통해 검색 문서에 액세스할 수 있습니다.
http://127.0.0.1:8001/apis/logging.gdc.goog/v1
http://127.0.0.1:8001/apis/monitoring.gdc.goog/v1
http://127.0.0.1:8001/apis/observability.gdc.goog/v1
리소스 예시
이 섹션에는 관측 가능성 KRM API를 사용하는 리소스 예시가 포함되어 있습니다.
로깅 그룹
다음은 project-1
프로젝트의 특정 서비스에서 로그를 수집하는 LoggingTarget
커스텀 리소스의 예시입니다.
# Configures a log scraping job
apiVersion: logging.gdc.goog/v1
kind: LoggingTarget
metadata:
# Choose a namespace that matches the namespace of the workload pods
namespace: project-1
name: my-service-logging-target
spec:
# Choose a matching pattern that identifies the pods for this job
# Optional
# Relationship between different selectors: 'AND'
selector:
# The clusters to collect logs from.
# The default configuration is to collect logs from all clusters.
# The relationship between different clusters is an 'OR' relationship.
# For example, the value '["admin", "system"]' indicates to consider
# the admin cluster 'OR' the system cluster.
# Optional
matchClusters:
- cluster-1
- cluster-2
# The pod name prefixes to collect logs from.
# The Observability platform scrapes all pods with names
# that start with the specified prefixes.
# The values must contain '[a-z0-9-]' characters only.
# The relationship between different list elements is an 'OR' relationship.
# Optional
matchPodNames:
- pod-1
- pod-2
# The container name prefixes to collect logs from.
# The Observability platform scrapes all containers with names
# that start with the specified prefixes.
# The values must contain '[a-z0-9-]' characters only.
# The relationship between different list elements is an 'OR' relationship.
# Optional
matchContainerNames:
- container-1
- container-2
# Choose the predefined parser for log entries.
# Use parsers to map the log output to labels and extract fields.
# Specify the log format.
# Optional
# Options: klog_text, klog_json, klogr, gdch_json, json
parser: klog_text
# Specify an access level for log entries.
# The default value is 'ao'.
# Optional
# Options: ao, pa, io
logAccessLevel: ao
# Specify a service name to be applied as a label
# For user workloads consider this field as a workload name
# Required
serviceName: service-name
# The additional static fields to apply to log entries.
# The field is a key-value pair, where the field name is the key and
# the field value is the value.
# Optional
additionalFields:
app: workload2
key: value
모니터링 그룹
다음은 project-1
프로젝트의 워크로드에서 측정항목을 수집하는 MonitoringTarget
커스텀 리소스의 예시입니다.
apiVersion: monitoring.gdc.goog/v1
kind: MonitoringTarget
metadata:
# Choose the same namespace as the workload pods
namespace: project-1
name: string
spec:
# Choose matching pattern that identifies pods for this job
# Optional
# Relationship between different selectors: AND
selector:
# Choose clusters to consider for this job
# Optional
# List
# Default: All clusters applicable to this project.
# Relationship between different list elements: OR
matchClusters:
- string
# Choose pod-labels to consider for this job
# Optional: Map of key-value pairs.
# Default: No filtering by label.
# Relationship between different pairs: AND
matchLabels:
key1: value1
# Choose annotations to consider for this job
# Optional: Map of key-value pairs
# Default: No filtering by annotation
# Relationship between different pairs: AND
matchAnnotations:
key1: value1
# Configure the endpoint exposed for this job
podMetricsEndpoints:
# Choose port either via static value or annotation
# Optional
# Annotation takes priority
# Default: static port 80
port:
value: integer
annotation: string
# Choose path either via static value or annotation
# Optional
# Annotation takes priority
# Default: static path /metrics
path:
value: string
annotation: string
# Choose scheme either via static value (http or https) or annotation
# Optional
# Annotation takes priority
# Default: static scheme http
scheme:
value: string
annotation: string
# Choose the frequency to scrape the metrics endpoint defined in podMetricsEndpoints
# Optional
# Default: 60s
scrapeInterval: string
# Dynamically rewrite the label set of a target before it gets scraped.
# https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
# Optional
# Default: No filtering by label
metricsRelabelings:
- sourceLabels:
- string
separator: string
regex: string
action: string
targetLabel: string
replacement: string
관측 가능성 그룹
다음은 platform-obs
프로젝트 네임스페이스에서 대시보드의 스토리지 크기를 업데이트하는 ObservabilityPipeline
커스텀 리소스의 예시입니다.
# Configure observability pipeline
apiVersion: observability.gdc.goog/v1
kind: ObservabilityPipeline
metadata:
# Don't change the namespace or name.
namespace: platform-obs
name: observability-config
spec:
...
monitoring:
grafana:
storageSize: 1Gi # Configure the new storage size for dashboards in the project.
...