728x90

모니터링(Grafana, Prometheus)/Grafana 14

Grafana database is locked

Grafana 사용 시 metrics을 수집하는 쿼리가 많으면database is locked이라는 에러가 뜬다.특히 alert 전송을 걸어두면 해당 에러가 생길 때마다 alert이 날아온다. 이런 경우 grafana.db을 mysql 같은 다른 db로 전환해도 되지만SQLite3를 그대로 쓰면서 가장 간단하게 해당 오류를 해결하는 방법이 있다.#grafana.db sqlite3 journal_mode 변경sudo sqlite3 /var/lib/grafana/grafana.db 'pragma journal_mode=wal;'#모드 변경 확인sqlite3Pragma journal_mode;출력 결과 : wal해당 작업을 하고 나면grafana.db-wal, grafana.db-shm 두가지 파일이 더 생긴..

Grafana alert webhook x509 unhandled critical extension

Grafana에서 webhook으로 Alert을 전송할 때https를 사용한다면 "x509 unhandled critical extension" 이런 에러가 발생한다. 해당 문제는 인증서 문제다.해결하려면 root 인증서를 grafana가 운영되고 있는 리눅스 서버에 등록해 주면 된다. Linux OS 인증서 등록cp root.crt /usr/local/share/ca-certificatesupdate-ca-certificates 일반적인 경우는 인증서를 등록해 주면 되지만 인증서를 등록해도 계속해서"x509 unhandled critical extension" 에러 메시지가 발생하는 경우가 있다. Grafana는 Go 언어로 작성되어 있고, Go의 TLS 라이브러리는Authority Key Identi..

grafanadb mig (sqlite3 to mysql)

사전 설치 필요 sudo apt-get install gawk => escape.awk 파일 사용하기 위함 sudo apt-get install sqlite3 => sqlitedump.sh를 사용하기 위함 (sqlite 3.31.1+) => grafanadb만 있으면 한 서버에서 스크립트를 만들어도 상관없음 sudo apt-get install docker-compose escape.awk sqlitedump.sh 파일 로컬에 받고 권한 수정 grafana db에서 sql 추출 grafana-server 중지 후 sql 추출 sudo ./sqlitedump.sh /var/lib/grafana/grafana.db > grafana.sql mysql container 생성전 작업(docker-compose ..

Grafana version 9 Alert 이미지 첨부하기(include image)

2가지 설정이 필요하다. 1.image renderer plugin 설치 image renderer가 설치 됐는지 확인하려면 패널에서 Share 부분을 선택하면 된다. image renderer plugin 설치 전이면 아래 이미지처럼 not installed라고 뜬다. grafana-image-renderer 설치 명령어 grafana-cli plugins install grafana-image-renderer 설치방법 참고 사이트 https://grafana.com/grafana/plugins/grafana-image-renderer/ Grafana Image Renderer plugin for Grafana | Grafana Labs Installing plugins on a Grafana Clou..

Grafana Alert silences

Grafana Alert 세팅 후 Silences라는 기능이 있다. 해당 기능은 적용한 시간 동안 제외 시켜둔 알람만 발생시키지 않는 기능이다. 물론 Alert을 전송하진 않지만 Alert 기능은 정상작동 중이라 show state history 정보는 확인이 가능하다. 해당 기능을 추가하는 방법은 간단하다. 우선 Alerting > Silences를 선택하면 New silence라는 버튼이 보인다. 해당 버튼을 클릭하면 아래 이미지 화면이 나오고 Silences start and end => Alert을 받지 않을 시간 세팅 Mathcing tables => Alert을 받지 않을 instance 세팅 여기서 Matching tables를 적용을 시키려면 우선 세팅한 alert을 보면 아래 이미지처럼 ..

Grafana alert or 조건 사용

Grafana에서 Alert 설정하는 부분을 확인하고 싶다면 아래 링크를 확인하시길 바란다. https://babbeolicoding.tistory.com/27 Grafana Alert 설정하기-2(Alert 조건 설정) 1. Datasource 선택 및 Query 작성 Reduce -> 각 인스턴스 하나하나 개별로 검토 Math -> 각 인스턴스의 결과값으로 조건 확인 A => 쿼리 B => 쿼리에서 나오는 인스턴스 각각의 결과값 C => 각 인스턴스의 결 babbeolicoding.tistory.com 보통 Alert에서 or 조건문을 사용할 땐 마지막 조건문 Math 부분에 "$B > 0 || $C > 0" 이렇게 조건을 넣는다. 어느날 or 조건을 세팅하고 있었는데 자꾸 Math에서 조건문에 No..

Grafana Alert 설정하기-4(No Data Alert 설정)

Grafana에서 Alert을 설정할때 아래 이미지처럼 "No data"로 metrics이 수집이 안되는 경우 보통 Alert이 날아간다. 하지만 경우에 따라 No data인 경우가 정상이고 metrics이 수집되는 경우 비정상인 경우도 필요하다. 이런 경우는 Alert을 설정할때 Configure no data and error handing 부분을 설정해주면 No data인 경우도 Alert을 보내지 않을 수 있다. Alert을 설정할때 Configure no data and error handing 부분을 클릭하면 Alert state if no data or all values are null 부분이 보통 No Data로 되어있다. 이 설정은 metrics이 아무것도 수집되지 않는 경우 즉 No ..

Grafana Alert 설정하기-3(Alert 분기처리)

Grafana로 Alert을 보낼 때 분기처리가 가능하다.(참고로 grafana 9 버전 기준) 예를 들어 설명하자면 아래와 같다. A조건 => telegram으로 전송 B조건 => email으로 전송 C조건 => slack으로 전송 분기처리를 위해 Alert을 만들때 Folder명이나 Labels의 key와 Value를 통해 구분이 가능하다. 우선 분기처리 전 정책을 생성해야 하는데 Notification policies > New specific policy에서 추가하면 된다. 아래 이미지처럼 세팅해서 사용가능하다. grafana_folder가 groupA일때는 test라는 Contact point로 알림을 grafana_folder가 groupB인 경우는 test2라는 Contact point로 알..

Grafana Alert 템플릿 커스텀 및 사용하기

우선 Template을 등록하는 방법은 아래와 같다. 1. Alerting에서 Contact points 탭을 선택 후 "New template"을 선택 2. Template 이름 입력 및 Content를 작성 3. Template Data에 마우스를 가져가면 아래처럼 팝업이 뜨는데 참고해서 작성 이번에는 Template을 사용하는 방법에 대해서 알아보자 우선 telegram을 연동하고 test 알림을 보내면 기본적으로 아래 형태로 메시지가 온다. **Firing** Value: [no value] Labels: - alertname = TestAlert - instance = Grafana Annotations: - summary = Notification test Silence: http://loca..

Grafana Alert 설정하기-2(Alert 조건 설정)

1. Datasource 선택 및 Query 작성 Reduce -> 각 인스턴스 하나하나 개별로 검토 Math -> 각 인스턴스의 결과값으로 조건 확인 A => 쿼리 B => 쿼리에서 나오는 인스턴스 각각의 결과값 C => 각 인스턴스의 결과값을 기준으로 조건 확인(사용시 $를 붙여서 사용한다) Grafana 버전이 올라가면서 각 instance마다 독립적으로 Alert을 받을 수 있다. ex) Grafana 예전 버전(쿼리 전체를 기준으로 하나의 Alert으로 작동) a,b,c,d,e instance 중 a가 alert 발생한 뒤 b가 alert 조건에 해당되도 추가적으로 alert이 오지 않음 ex) Grafana 최신 버전(각 instance가 독립적으로 Alert으로 작동) a,b,c,d,e in..

728x90