TheKoguryo's Tech Blog

 Version 2024.05.05

Warning

This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.

12.3.1 Install Grafana on Compute VM

Create Compute Instance

  1. Go to the Compute Instance creation screen.

  2. Select the image source as the Oracle Linux Cloud Developer Image image from the Oracle Images list.
    Oracle Cloud Developer Image has development tools such as OCI CLI already installed. image-20220117115909851

  3. Create a Compute instance.

  4. Copy the OCID of the created Compute instance.

OCI CLI - Instance Principal Settings

In order to use the OCI API without additional authentication on the Compute instance, you need to set the Instance Principal. The procedure is to add a Compute instance to a Dynamic Group and grant permissions to that Group.

Dynamic Group Settings
  1. Open the navigation menu in the OCI console. Go to Identity & Security > Identity > Dynamic Groups.

  2. Click Create Dynamic Group.

  3. Click Rule Builder on the right side of the rule creation section to add a rule through the tool.

    • Matching criteria: Instance OCID
    • VALUE: OCID of the copied Compute instance image-20220117120626795
  4. Enter NAME and DESCRIPTION to create a Dynamic Group.

    • Name: Ex) MyInstancePrincipleDynamicGroup

    image-20220117120954288

Policy settings
  1. Go to Identity & Security > Identity > Policies.

  2. Click Create Policy.

  3. Create a policy with the following two permissions.

    allow dynamic-group <dynamic group you created> to read metrics in tenancy
    allow dynamic-group <created dynamic group> to read compartments in tenancy
    
  4. Policy creation screen image-20220117121949263

Check OCI CLI connection
  1. Connect to the Compute instance created earlier with SSH.

  2. Connect with the Instance Principal method with the following command. You can check the connection even though the OCI CLI config file is not set.

    oci os ns get --auth instance_principal
    
    • Connection example

      [opc@mygrafana ~]$ oci os ns get --auth instance_principal
      {
        "data": "thekoguryo"
      }
      [opc@mygrafana ~]$
      

Install Grafana

  1. Connect to the Compute instance and install Grafana by executing the following commands in order.

    wget https://dl.grafana.com/oss/release/grafana-8.1.8-1.x86_64.rpm
    sudo yum install -y grafana-8.1.8-1.x86_64.rpm
    sudo systemctl start grafana-server
    sudo grafana-cli plugins install oci-metrics-datasource
    sudo firewall-cmd --permanent --add-port=3000/tcp
    sudo firewall-cmd --reload
    sudo systemctl restart grafana-server
    
    • Execution example

      [opc@grafana ~]$ wget https://dl.grafana.com/oss/release/grafana-8.1.8-1.x86_64.rpm
      --2022-01-17 04:40:23--  https://dl.grafana.com/oss/release/grafana-8.1.8-1.x86_64.rpm
      Resolving dl.grafana.com (dl.grafana.com)... 151.101.54.217, 2a04:4e42:d::729
      Connecting to dl.grafana.com (dl.grafana.com)|151.101.54.217|:443... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 56048174 (53M) [application/x-redhat-package-manager]
      Saving to: ‘grafana-8.1.8-1.x86_64.rpm’
      
      grafana-8.1.8-1.x86_64.rpm             100%[===========================================================================>]  53.45M  15.9MB/s    in 4.2s
      
      2022-01-17 04:40:28 (12.6 MB/s) - ‘grafana-8.1.8-1.x86_64.rpm’ saved [56048174/56048174]
      
      [opc@grafana ~]$ sudo yum install grafana-8.1.8-1.x86_64.rpm
      Last metadata expiration check: 0:02:06 ago on Mon Jan 17 04:38:24 2022.
      Dependencies resolved.
      =========================================================================================================================
       Package                  Architecture            Version                  Repository                     Size
      =========================================================================================================================
      Installing:
       grafana                  x86_64                  8.1.8-1                  @commandline                   53 M
      
      Transaction Summary
      =========================================================================================================================
      Install  1 Package
      
      Total size: 53 M
      Installed size: 178 M
      Downloading Packages:
      Running transaction check
      Transaction check succeeded.
      Running transaction test
      Transaction test succeeded.
      Running transaction
        Preparing        :                                                                                                                                   1/1
        Installing       : grafana-8.1.8-1.x86_64                                                                                                            1/1
        Running scriptlet: grafana-8.1.8-1.x86_64                                                                                                            1/1
      ### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
       sudo /bin/systemctl daemon-reload
       sudo /bin/systemctl enable grafana-server.service
      ### You can start grafana-server by executing
       sudo /bin/systemctl start grafana-server.service
      
      POSTTRANS: Running script
      
        Verifying        : grafana-8.1.8-1.x86_64                                                                                                            1/1
      
      Installed:
        grafana-8.1.8-1.x86_64
      
      Complete!
      [opc@grafana ~]$ sudo systemctl start grafana-server
      [opc@grafana ~]$ sudo grafana-cli plugins install oci-metrics-datasource
      ✔ Downloaded oci-metrics-datasource v3.0.0 zip successfully
      
      Please restart Grafana after installing plugins. Refer to Grafana documentation for instructions if necessary.
      
      [opc@grafana ~]$ sudo firewall-cmd --permanent --add-port=3000/tcp
      success
      [opc@grafana ~]$ sudo firewall-cmd --reload
      success
      [opc@grafana ~]$ sudo systemctl restart grafana-server
      [opc@grafana ~]$
      
  2. Open port 3000 to Ingress of the Security List of the VM where Grafana is installed.

  3. Grafana Login

    Connect to the Compute instance where Grafana is installed through port 3000. The default access account is admin/admin.

참고 사이트



As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.

Last updated on 17 Jan 2022