12.3.1 Compute VM에 Grafana 설치
Compute Instance 만들기
-
Compute Instance 생성 화면으로 이동합니다.
-
Compute 인스턴스를 생성합니다.
- 예, OS Image: Oracle Linux 9
-
생성된 Compute 인스턴스의 OCID를 복사해 둡니다.
그라파나가 설치된 Compute Instance에 권한 설정하기
Compute 인스턴스에 설치된 그라파나 OCI 플러그인이 OCI API를 통해 OCI 메트릭 정보 등을 가져오기 위해서는 관련 권한이 필요합니다. Compute 인스턴스에게 주는 권한은 Instance Principal을 설정해야 합니다. 그 절차는 Compute 인스턴스를 Dynamic Group으로 지정하고, 해당 Group에 권한을 주는 방식입니다.
Dynamic Group 설정
-
OCI 콘솔에서 내비게이션 메뉴를 엽니다. Identity & Security > Identity > Domains로 이동한 후, Default Domain을 클릭합니다.
-
메뉴에서 Dynamic groups로 이동합니다.
-
Create Dynamic Group을 클릭합니다.
- Name: 예) grafana-instance-dynamic-group
-
룰 작성 부분 오른쪽 Rule builder를 클릭하여 툴을 통해 룰을 추가합니다.
-
매칭 기준: Instance OCID
-
Value: 복사해둔 Compute 인스턴스의 OCID
-
-
Dynamic Group을 생성합니다.
Policy 설정
-
OCI 콘솔에서 내비게이션 메뉴를 엽니다. Identity & Security > Identity > Policies로 이동합니다.
-
Create Policy을 클릭합니다.
- Name: 예, grafana-instance-policy
-
다음 두 권한을 가지는 Policy를 생성합니다.
allow dynamic-group grafana-instance-dynamic-group to inspect tenancies in tenancy allow dynamic-group grafana-instance-dynamic-group to read metrics in tenancy allow dynamic-group grafana-instance-dynamic-group to read compartments in tenancy
-
Policy를 생성합니다.
OCI CLI 접속 확인
-
SSH로 앞서 생성한 Compute 인스턴스로 접속합니다.
-
OCI CLI를 설치합니다.
# Oracle Linux 9 sudo dnf -y install oraclelinux-developer-release-el9 sudo dnf install python39-oci-cli
-
Instance Principal 방식으로 접속이 되는 지 확인합니다. OCI CLI config 파일을 설정하지 않았는데 접속되는 것을 확인 할 수 있습니다.
oci os ns get --auth instance_principal
-
접속 예시
[opc@grafana ~]$ oci os ns get --auth instance_principal { "data": "xxxxxxxxxxxx" }
-
Grafana + OCI Metrics plugin for Grafana 설치
-
oci-grafana-metrics의 Grafana 지원버전을 확인합니다.
- 작성일 기준 v6.0.0 부터 Grafana 11 지원
- 참고: https://github.com/oracle/oci-grafana-metrics/releases
-
Compute 인스턴스에 접속하여 다음 명령들을 순서대로 실행하여 Grafana 11 버전을 설치합니다.
sudo yum install -y https://dl.grafana.com/grafana/release/11.6.6/grafana_11.6.6_17870560488_linux_amd64.rpm sudo systemctl daemon-reload sudo systemctl start grafana-server sudo systemctl status grafana-server
-
Grafana 재시작
sudo systemctl restart grafana-server
-
OCI Metrics Plugin for Grafana 설치
- 작성일 기준 최신 버전의 멀티 리전 조회 이슈가 있어, 6.0.3 버전을 설치합니다.
- https://github.com/oracle/oci-grafana-metrics/issues/328
sudo grafana-cli plugins install oci-metrics-datasource 6.0.3
-
Grafana 포트 개방
-
OS 레벨에서 포트를 개방합니다.
sudo firewall-cmd --permanent --add-port=3000/tcp sudo firewall-cmd --reload
-
Grafana가 설치된 Compute 인스턴스가 속한 Security List의 Ingress에 3000번 포트를 개방합니다.
-
-
Grafana 로그인
브라우저를 통해 Grafana가 설치된 Compute 인스턴스에 3000포트로 접속합니다. 기본 접속 계정은 admin/admin 입니다.
참고 사이트
- https://grafana.com/blog/2019/02/25/oracle-cloud-infrastructure-as-a-data-source-for-grafana/
- https://blogs.oracle.com/cloudnative/data-source-grafana
- https://grafana.com/grafana/plugins/oci-metrics-datasource/
- https://github.com/oracle/oci-grafana-metrics/blob/master/docs/linux.md
이 글은 개인으로서, 개인의 시간을 할애하여 작성된 글입니다. 글의 내용에 오류가 있을 수 있으며, 글 속의 의견은 개인적인 의견입니다.