사용량 인사이트 로그 내보내기
사용량 인사이트 로그 내보내기 (Export logs of usage insights)
사용량 로그를 Loki로 내보내면 직접 쿼리하고, 대시보드 오류, 가장 활발한 조직, 가장 많이 사용된 쿼리 등 자신에게 가장 중요한 정보의 대시보드를 만들 수 있어요. Grafana Cloud에서는 이 구성이 프로비저닝된 대시보드와 함께 자동으로 처리돼요.
출처: 문서
본문
참고: 이 기능은 Grafana Enterprise와 일부 Grafana Cloud 요금제에서 사용할 수 있어요.
사용량 인사이트 로그 (Usage insights logs)
사용량 인사이트 로그는 특정 사용자 활동을 나타내는 JSON 객체예요. 다음 이벤트 때마다 로그가 생성돼요: 데이터 요청이 있을 때, 대시보드 조회가 있을 때.
형식 (Format)
사용량 인사이트 로그는 다음 필드를 포함해요. 뒤에 *가 붙은 필드는 항상 사용 가능하고, 나머지는 기록된 이벤트에 따라 달라져요.
| 필드 이름 | 타입 | 설명 |
|---|---|---|
| eventName * | string | 이벤트 유형. data-request 또는 dashboard-view |
| folderName * | string | 대시보드 폴더 이름 |
| dashboardName * | string | 이벤트가 발생한 대시보드 이름 |
| dashboardId * | number | 이벤트가 발생한 대시보드 ID |
| datasourceName | string | 쿼리된 데이터 소스 이름 |
| datasourceType | string | 쿼리된 데이터 소스 유형. 예: prometheus, elasticsearch, loki |
| datasourceId | number | 쿼리된 데이터 소스 ID |
| panelId | number | 쿼리 패널의 ID |
| panelName | string | 쿼리 패널의 이름 |
| error | string | 쿼리가 반환한 오류 |
| duration | number | 쿼리 지속 시간 |
| source | string | 쿼리 소스. 예: dashboard 또는 explore |
| orgId * | number | 사용자 조직의 ID |
| orgName * | string | 사용자 조직의 이름 |
| timestamp * | string | 요청이 이루어진 날짜·시간. UTC, RFC3339 형식 |
| tokenId * | number | 사용자 인증 토큰의 ID |
| username * | string | 요청한 Grafana 사용자의 이름 |
| userId * | number | 요청한 Grafana 사용자의 ID |
| totalQueries * | number | 데이터 요청에 대해 실행된 쿼리 수 |
| cachedQueries * | number | 캐시에서 가져온 쿼리 수 |
구성 (Configuration)
주의: Grafana Cloud는 사용량 인사이트용 프로비저닝된 대시보드를 제공해요. 사용량 인사이트를 별도의 Loki 인스턴스로 내보내면 이 대시보드들이 사용량 인사이트 데이터를 받지 못해요. 이는 Grafana Cloud에서 이 기능의 현재 제한 사항이에요.
로그를 내보내려면 사용량 인사이트 기능을 활성화하고 구성 파일에 내보내기 위치를 구성하세요:
[usage_insights.export]
# Enable the usage insights export feature
enabled = true
# Storage type
storage = loki
storage 유형의 옵션은 loki와 logger(Grafana Enterprise 8.2에서 추가)예요.
storage 유형이 loki면 Grafana를 Loki 수집 서버로 내보내도록 구성해야 해요. 이를 위해 Loki가 설치되어 있어야 해요.
[usage_insights.export.storage.loki]
# Set the communication protocol to use with Loki (can be grpc or http)
type = grpc
# Set the address for writing logs to Loki (format must be host:port)
url = localhost:9095
# Defaults to true. If true, it establishes a secure connection to Loki
tls = true
# Set the tenant ID for Loki communication, which is disabled by default.
# The tenant ID is required to interact with Loki running in multi-tenant mode.
tenant_id =
# How long to wait before sending a request to Loki with the batch of events. Uses duration format: e.g. 5s, 1m
# Whatever happens first between `batch_wait_duration` and `batch_size_bytes` will trigger the batch to be sent to Loki.
# If the wait duration is very long and the `batch_size_bytes` is very high, events may take a long time to be sent.
batch_wait_duration = 5s
# How many events (in bytes) to accumulate in a single batch before sending it to Loki.
# Whatever happens first between `batch_wait_duration` and `batch_size_bytes` will trigger the batch to be sent to Loki.
# If you wish to always wait for the `batch_wait_duration`, set this to a very high number.
batch_size_bytes = 102400 # 100KiB
logger를 사용하면 사용량 인사이트가 Grafana 서버 로그에 출력돼요. logger storage 유형을 구성하는 옵션은 없어요.
Grafana에서 Loki 사용량 인사이트 시각화
로그를 Loki로 내보내면 Grafana 대시보드를 만들어 Grafana 인스턴스 사용량을 이해할 수 있어요.