CATCHV Blog

[Grafana] loki logcli 사용법 본문

Dev/Grafana

[Grafana] loki logcli 사용법

catchv 2023. 3. 8. 14:00
반응형

1. 설치

https://github.com/grafana/loki/releases 에서 플랫폼에 맞는 것을 다운로드 받는다.

# 다운로드 받기
$ wget https://github.com/grafana/loki/releases/download/v2.7.4/logcli-linux-amd64.zip

# 압축 해제
$unzip logcli-linux-amd64.zip

 

2. logcli에서 사용할 loki를 설정한다.

# export LOKI_ADDR=http://<loki 서버 주소>:<loki http port>
export LOKI_ADDR=http://loki:3100

 

3. loki의 설정된 job 리스트 확인

$ ./logcli-linux-amd64 labels job
2023/03/08 04:48:29 http://loki:3100/loki/api/v1/label/job/values?end=1678250909484905582&start=1678247309484905582
varlogs


4. job에 저장된 데이터 확인

(  varlogs 저장된 데이터는 mysql의 errorlog를 저장하고 있음 )

$ ./logcli-linux-amd64 query '{job="varlogs"}'
2023/03/08 04:50:19 http://loki:3100/loki/api/v1/query_range?direction=BACKWARD&end=1678251019157484315&limit=30&query=%7Bjob%3D%22varlogs%22%7D&start=1678247419157484315
2023/03/08 04:50:19 Common labels: {filename="/var/log/mysqld.log", job="varlogs"}

2023-03-08T04:50:13Z {} 2023-03-08T04:50:12.844220Z 50 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'      
2023-03-08T04:49:52Z {} 2023-03-08T04:49:52.844485Z 49 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
반응형
Comments