반응형
728x170
정의
그라파나는 오픈소스로 열려있는 모니터링 툴이며
프로메테우스와 같이 붙어다니는 경우가 많음
설치
#설치
wget https://dl.grafana.com/oss/release/grafana-<version>.linux-amd64.tar.gz
#압축 해제
tar -zxvf grafana-<version>.linux-amd64.tar.gz
#디렉토리 설정
sudo mv grafana-<version> /usr/local/grafana
#config 파일 입력
sudo nano /usr/local/grafana/conf/grafana.ini
configuration ( grafana.ini )
[server]
http_port = 3000
protocol = http
domain = localhost
root_url = %(protocol)s://%(domain)s:%(http_port)s/
[database]
type = sqlite3
path = data/grafana.db
[security]
admin_user = admin
admin_password = admin
Server
| Field | Description |
| http_port | The port that the Grafana server should listen on. |
| protocol | The protocol (http or https) that the Grafana server should use. |
| domain | The domain or hostname that the Grafana server should respond to. |
| root_url | The base URL of the Grafana server. |
| enforce_domain | If true, only requests to the specified domain will be accepted |
| serve_from_sub_path | The subpath to serve Grafana from. |
| router_logging | Enable router request logging. |
| static_root_path | The path to the static files, used for the frontend. |
| enable_gzip | Enable gzip compression of responses. |
Database
| Field |
Description |
| type | The type of database that Grafana should use (e.g. sqlite3, mysql, etc.) |
| path | The location of the database file (for sqlite3) |
| host | The hostname of the database server. |
| name | The name of the database. |
| user | The username to use when connecting to the database. |
| password | The password to use when connecting to the database. |
| ssl_mode | When set to "require", Grafana will require SSL |
Analytics
| Field | Description |
| reporting_enabled | Enable sending usage statistics to Grafana Labs. |
Paths
| Field | Description |
| data | The directory where Grafana stores the SQLite3 database and other data. |
| logs | The directory where Grafana stores its log files. |
| plugins | The directory where Grafana stores its plugins. |
| provisioning | The directory where provisioning files are stored. |
| temp | The directory used for temporary files. |
Security
FieldDescription
| Field | Description |
| admin_user | The username of the initial admin user. |
| admin_password | The password of the initial admin user. |
| login_remember_days | Number of days the remember me cookie should be valid for. |
| secret_key | The key to use for encrypting secure cookies. |
| cookie_username | The name of the cookie that stores the username. |
| cookie_remember_name | The name of the cookie that stores the remember me token. |
| cookie_secure | If true, the cookies will only be sent over https. |
| disable_gravatar | If true, Grafana will not try to load gravatars. |
| allow_embedding | Allow embedding grafana in iframes. |
Log
FieldDescription
| Field | Description |
| mode | The log mode (console or file) |
| level | The log level (debug, info, warn, or error) |
| filenames | The names of the log files (when using file mode) |
| format | The log format (logfmt, json, or text) |
SMTP
FieldDescription
| Field | Description |
| enabled | Enable sending email notifications. |
| host | The hostname of the SMTP server. |
| user | The username to use when authenticating to the SMTP server. |
| password | The password to use when authenticating to the SMTP server. |
| from_address | The email address to use as the "from" address for notifications. |
| from_name | The name to use as the "from" name for notifications. |
Alerting
FieldDescription
| Field | Description |
| enabled | Enable alerting engine. |
| execute_alerts | Execute alerts even if alerting engine is disabled. |
| alert_relabel_configs | Array of alert relabel configs |
| pagerduty_enabled | Enable PagerDuty notifications. |
| pagerduty_service_key | PagerDuty service key |
| alert_timezone | Timezone for alert evaluation and notifications. |
| slack_enabled | Enable Slack notifications. |
| slack_webhook_url | Slack webhook URL. |
실행
Prometheus 가 /usr/local/bin 에 존재하고 Grafana가 /usr/sbin 에 있다는 가정
#서비스 등록
sudo nano /etc/systemd/system/grafana-server.service
#grafana-server.service
#=======================
[Unit]
Description=Grafana
Wants=network-online.target
After=network-online.target
[Service]
User=grafana
Group=grafana
Type=simple
ExecStart=/usr/local/grafana/bin/grafana-server -config /usr/local/grafana/conf/grafana.ini
[Install]
WantedBy=multi-user.target
#====================
#서비스 시작 및 스타트업 서비스 등록
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
sudo systemctl enable grafana-server
Grafana는 웹 인터페이스를 제공함
http://<grafana_host>:<grafana_port> 포맷을 가지는 것이 보통이며
기본적으로는 http://localhost:3000를 이용함
해당 웹 UI 에서 Create a New Source 프로메테우스의 Metric을 가져올 수 있음
http://<prometheus_host>:<prometheus_port> 과 같은 형식으로 프로메테우스 소스를 지정함
참고링크
https://prometheus.io/docs/visualization/grafana/
728x90
반응형
그리드형