레이블이 grafana인 게시물을 표시합니다. 모든 게시물 표시
레이블이 grafana인 게시물을 표시합니다. 모든 게시물 표시

2020년 1월 7일 화요일

Grafana & graphite 그리고 모니터링 #06.

CentOS 7.x 버전에 설치하기.

 

이전에 기록했던 CentOS 6.x 버전에 설치하기대로 설치가 안된다.

 

1. Docker 설치

 

  
1
yum install docker
cs


2. pip upgrade

 

  
1
pip install --upgrade pip
cs


3. Docker 설정 변경

 

   /etc/sysconfig/docker 파일에서 다음 그림과 같이 설정을 수정


4. Docker 시작하기.


  
1
2
3
systemctl enable docker.service
systemctl start docker.service
systemctl status docker.service
cs



5. Docker image build.

 

  
1
docker build -f ./Dockerfile --tag graphite:1.0 ./
cs



6. Rpmdb checksum is invalid: dCDPT(pkg checksums): libXext.x86_64 0:1.3.3-3.el7 - u


   하지만, 실패 ㅠㅠ



   여러가지 해결 방법이 존재한다.

7. 해결 방법

 

   제일 처음에 다음과 같이 Docker overlay fs 추가하거나,

  
1
RUN yum -y install yum-plugin-ovl
cs


   다른 방법으로

  
1
RUN yum install -y graphite-web;yum clean all
cs


   혹은

  
1
RUN rpm --rebuilddb && yum install -y graphite-web
cs



  

2017년 8월 11일 금요일

Grafana docker upgrading.

기억력이 감퇴해서 매번 검색해야 하는 머리를 위해.


거대 프로젝트가 아니라 우리는 Database로 sqlite를 사용합니다.


1. 최선의 방법.


   Installing using Docker 문서를 천천히 읽고 container를 생성할 때 database와 환경
   설정 변수 경로를 host에 맵핑 시키기만 하면 backup / restore 과정이 없어도 됩니다.

  
1
2
3
4
$ docker run -d -p 3000:3000 \
    -v /var/lib/grafana:/var/lib/grafana \
    -e "GF_SECURITY_ADMIN_PASSWORD=secret" \
    grafana/grafana
cs


2. 업그레이드


  
1
2
3
4
docker pull grafana
docker stop my-grafana-container
docker rm my-grafana-container
docker run --name=my-grafana-container --restart=always -/var/lib/grafana:/var/lib/grafana
cs


3. 1번 방법으로 설치하지 않았을 경우.


   sqlite의 경우 grafana.db를 백업해야 합니다. 보통 /var/lib/grafana/grafana.db 경로에
   위치해 있고 설정 파일의 경우 /etc/grafana/grafana.ini 경로에 있습니다.
   설정 파일의 경우엔 버전에 따라 다를 수 있으므로 백업 후 그대로 복구하지 않고
   비교해보고 진행합니다.

   그 외 다른 Database를 사용하는 경우 백업은 Upgrading Grafana 문서를 참조합니다.

  

2017년 2월 16일 목요일

Grafana & graphite 그리고 모니터링 #05.

그런데 그래프가 하루만 그려진다.



모든 준비가 끝나 예쁜 그래프를 보면서 모니터링을 잘 할 수 있을거라 생각했지만...

1. 하루 살이.


   위 그림과 같이 이틀 동안의 그래프를 보도록 설정하고 데이터는 이미 충분히 오랫동안
   수집하고 있는 상태지만 다음 그림과 같이 보인다.


2. storage-schemas.conf.

   파일 이름과 같이 whisper database를 위한 schema를 정의하는 파일입니다.
   파일을 열어보면 앞 부분에 친절하게 적혀 있듯이 위에서부터 순서대로 적용되게 되어
   있어 파일 제일 뒤에 내용을 추가하면 적용되지 않습니다.
   이유는 [default_1min_for_1day] 항목에서 모두 만족하기 때문에 그 다음 항목이 적용
   대상인지 확인할 필요가 없기 때문입니다.

   어쨌든, 그럼 우리가 필요한 schema를 정의해 보도록 합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
#  [name]
#  pattern = regex
#  retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
 
# Carbon's internal metrics. This entry should match what is specified in
# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings
[carbon]
pattern = ^carbon\.
retentions = 60:90d
 
[sample]
pattern = ^sample\.
retentions = 60s:1d,5m:7d,30m:1y
 
[default_1min_for_1day]
pattern = .*
retentions = 60s:1d
cs

   그리고 graphite container를 재시작 해보지만 역시나 하루만 보이게 됩니다.

3. 해결 방법.

   Whisper database는 rrd와 마찬가지로 최초 schema에 맞춰 database를 생성하고 그 상태
   그대로 유지합니다. 일반적으로는 whisper database file을 삭제하고 재시작 하게 되면
   schema 변경에 맞춰 적용되겠지만 고맙게도 whisper-resize(.py) 라는 도구를
   지원합니다.

   http://github.com/graphite-project/whisper

   위 사이트를 방문해서 whisper-resize에 대한 설명을 확인해 보면 다음과 같이 되어
   있습니다.

   Usage: whisper-resize.py path timePerPoint:timeToStore [timePerPoint:timeToStore]*

   timePerPoint and timeToStore specify lengths of time, for example:

   60:1440      60 seconds per datapoint, 1440 datapoints = 1 day of retention
   15m:8        15 minutes per datapoint, 8 datapoints = 2 hours of retention
   1h:7d        1 hour per datapoint, 7 days of retention
   12h:2y       12 hours per datapoint, 2 years of retention


   Options:
     -h, --help            show this help message and exit
     --xFilesFactor=XFILESFACTOR
                           Change the xFilesFactor
     --aggregationMethod=AGGREGATIONMETHOD
                           Change the aggregation function (average, sum, last,
                           max, min)
     --force               Perform a destructive change
     --newfile=NEWFILE     Create a new database file without removing the
                           existing one
     --nobackup            Delete the .bak file after successful execution
     --aggregate           Try to aggregate the values to fit the new archive
                           better. Note that this will make things slower and use
                           more memory.

   그럼 이제 graphite container에 접속해서 whisper database 수정을 해보자.

1
whisper-resize ./5032.wsp 60s:1d 5m:7d 30m:1y
cs


   이제 다음 그림과 같이 그래프의 왼쪽 영역에도 나오기 시작한다.


2017년 2월 14일 화요일

Grafana & graphite 그리고 모니터링 #04.

Local storage에 데이터 저장하기.


Docker container가 자동 시작 되었지만 데이터가 container에 저장되게 되어 있어서,
성능 및 유지 보수 관점에서 문제가 된다. 데이터를 host에 저장하자.

1. Run shell script.

1
2
3
4
5
6
#!/bin/sh
 
carbon-cache --config=/etc/carbon/carbon.conf start
chown -R carbon:carbon /var/lib/carbon/rrd/
chown -R carbon:carbon /var/lib/carbon/whisper/
python /usr/lib/python2.7/site-packages/graphite/manage.py runserver 0:8000
cs

   이전 글에서 없었던 4, 5번 라인이 추가되었다. 이게 좀 웃긴데 container를 실행할 때
   --volume 옵션을 사용해서 host에 저장하게 되면 container의 경로의 소유자가 강제로
   root로 변경된다. 하지만 carbon의 기본 계정은 carbon이 되고 따라서 데이터가 저장될
   경로의 소유자도 carbon이어야 시계열 데이터가 정상적으로 저장이 된다.


2. Docker build script.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# VERSION 1.0
FROM centos:7.2.1511
MAINTAINER ships <ships@darts.kr>
 
RUN yum install -y epel-release
RUN cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime
 
RUN useradd pxuser
ADD ./Run.sh /home/pxuser/
RUN chmod +/home/pxuser/Run.sh
 
RUN yum install -y python-carbon
RUN yum install -y graphite-web
 
RUN django-admin syncdb --settings=graphite.settings --noinput
 
EXPOSE 8000
VOLUME ["/var/lib/carbon/rrd""/var/lib/carbon/whisper"]
 
WORKDIR /home/pxuser/
CMD ["./Run.sh"]
cs

   이전 글과 비교해서 특별한 것은 없고 작업 경로의 Run.sh이 실행 권한이 없을 경우
   이미지에 복사된 스크립트도 실행 권한이 없어서 실행이 안되는 문제를 해결하기 위해
   실행 권한을 부여하는 것과 저장소 관련 명령어 정도가 추가 되었다.


3. Docker run.

   이제 volume 옵션을 주고 실행하면 준비는 끝.
1
2
3
4
docker run --5338:2003 \              
              -/var/lib/carbon/rrd:/var/lib/carbon/rrd \              
              -/var/lib/carbon/whisper:/var/lib/carbon/whisper \              
              --name graphite graphite:1.0
cs