Grafanaインストール · 13 min read · Oct 28, 2025
Ubuntu 22.04にGrafana Linux監視ソフトウェアをインストールする方法

Grafanaは、無料でオープンソースの機能豊富なメトリクスダッシュボードおよびデータ視覚化ツールです。Graphite、Elasticsearch、OpenTSDB、Prometheus、InfluxDB用に設計されており、Webベースのインターフェースからメトリクスを監視します。マルチプラットフォームであり、データ収集、ストレージ、視覚化、共有のための100以上のプラグインがあります。データのアラートや通知を作成し、共有機能を通じてチームメイトとのコラボレーションを容易にします。
このチュートリアルでは、Ubuntu 22.04にGrafana 8をインストールする方法を説明します。
前提条件
- Ubuntu 22.04を実行しているサーバー。
- サーバーIPにポイントされた有効なドメイン名。
- サーバーに設定されたルートパスワード。
始めに
開始する前に、システムを最新のバージョンに更新することをお勧めします。以下のコマンドを使用してすべてのパッケージを更新できます。
apt-get update -y
apt-get upgrade -yすべてのパッケージがアップグレードされたら、以下のコマンドを使用して他の必要な依存関係をインストールします。
apt-get install gnupg2 curl wget git software-properties-common -yすべてのパッケージがインストールされたら、次のステップに進むことができます。
Ubuntu 22.04にGrafana 8をインストールする
デフォルトでは、GrafanaはUbuntu 22.04のデフォルトリポジトリには含まれていません。したがって、APTにGrafanaリポジトリを追加する必要があります。以下のコマンドを使用して追加できます。
curl https://packages.grafana.com/gpg.key | apt-key add -
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"リポジトリが追加されたら、リポジトリキャッシュを更新し、以下のコマンドを使用してGrafanaをインストールします。
apt-get update -y
apt-get install grafana -yGrafanaがインストールされたら、以下のコマンドを使用してGrafanaサービスを開始し、有効にします。
systemctl start grafana-server
systemctl enable grafana-server以下のコマンドを使用してGrafanaサービスのステータスを確認することもできます。
systemctl status grafana-server以下の出力が得られます。
? grafana-server.service - Grafana instance
Loaded: loaded (/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-06 09:33:06 UTC; 7s ago
Docs: http://docs.grafana.org
Main PID: 69737 (grafana-server)
Tasks: 9 (limit: 2242)
Memory: 37.1M
CPU: 1.580s
CGroup: /system.slice/grafana-server.service
??69737 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-server.pid --packaging=deb cfg>
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=secrets t=2022-08-06T09:33:08.517381147Z level=info msg="Envelope encryption state" >
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=query_data t=2022-08-06T09:33:08.527197639Z level=info msg="Query Service initializa>
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=live.push_http t=2022-08-06T09:33:08.544920469Z level=info msg="Live Push Gateway in>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert t=2022-08-06T09:33:13.723313517Z level=warn msg="failed to delete old am con>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=infra.usagestats.collector t=2022-08-06T09:33:13.885398731Z level=info msg="register>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=server t=2022-08-06T09:33:13.886028388Z level=info msg="Writing PID file" path=/run/>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=http.server t=2022-08-06T09:33:13.900761945Z level=info msg="HTTP Server Listen" add>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert t=2022-08-06T09:33:13.901994976Z level=info msg="warming cache for startup"
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert.multiorg.alertmanager t=2022-08-06T09:33:13.902506414Z level=info msg="start>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=grafanaStorageLogger t=2022-08-06T09:33:13.926571246Z level=info msg="storage starti>
デフォルトでは、Grafanaはポート3000でリッスンします。以下のコマンドを使用して確認できます。
ss -antpl | grep 3000以下の出力が得られます。
LISTEN 0 4096 *:3000 *:* users:(("grafana-server",pid=69737,fd=8)) GrafanaのリバースプロキシとしてNginxをインストールする
デフォルトでは、Grafanaはポート3000を介してアクセスできます。したがって、ポート80を介してアクセスできるようにするために、Nginxをリバースプロキシとしてインストールおよび構成する必要があります。まず、以下のコマンドを使用してNginxをインストールします。
apt-get install nginx -yNginxがインストールされたら、以下のコマンドを使用してNginxの仮想ホスト構成ファイルを作成します。
nano /etc/nginx/conf.d/grafana.conf以下の行を追加します。
server {
server_name grafana.example.com;
listen 80;
access_log /var/log/nginx/grafana.log;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}作業が完了したら、ファイルを保存して閉じます。次に、以下のコマンドを使用してNginxの構文エラーを確認します。
ginx -tすべてが正常であれば、以下の出力が得られます。
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful次に、構成変更を適用するためにNginxを再起動します。
systemctl restart nginx以下のコマンドを使用してNginxのステータスを確認することもできます。
systemctl status nginx以下の出力が得られます。
? nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-06 09:35:32 UTC; 4s ago
Docs: man:nginx(8)
Process: 70326 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 70327 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 70328 (nginx)
Tasks: 2 (limit: 2242)
Memory: 2.6M
CPU: 42ms
CGroup: /system.slice/nginx.service
??70328 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
??70329 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "```
## Grafanaダッシュボードにアクセスする
今、ウェブブラウザを開いて、URL http://grafana.example.comを使用してGrafanaのWebインターフェースにアクセスします。Grafanaのログインページにリダイレクトされます。

デフォルトの管理者ユーザー名、パスワードをadmin/adminとして提供し、ログインボタンをクリックします。Grafanaのパスワードリセット画面が表示されるはずです。

新しいパスワードを設定し、送信ボタンをクリックします。次の画面にGrafanaダッシュボードが表示されるはずです。

## Let's EncryptでGrafanaを保護する
次に、Let's Encrypt SSLをインストールおよび管理するためにCertbotクライアントパッケージをインストールする必要があります。
まず、以下のコマンドを使用してCertbotをインストールします。
apt-get install certbot python3-certbot-nginx -y
インストールが完了したら、以下のコマンドを実行して、ウェブサイトにLet's Encrypt SSLをインストールします。
certbot –nginx -d grafana.example.com
有効なメールアドレスを提供し、以下のようにサービス利用規約に同意するよう求められます。
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to cancel): [email protected]
Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory
(A)gree/(C)ancel: A
Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let’s Encrypt project and the non-profit organization that develops Certbot? We’d like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom.
(Y)es/(N)o: Y Obtaining a new certificate Performing the following challenges: http-01 challenge for grafana.example.com Waiting for verification… Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/conf.d/grafana.conf
次に、HTTPトラフィックをHTTPSにリダイレクトするかどうかを選択します。
1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you’re confident your site works on HTTPS. You can undo this change by editing your web server’s configuration.
Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel): 2
2を入力してEnterを押してインストールを完了します。以下の出力が表示されるはずです。
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/grafana.conf
Congratulations! You have successfully enabled https://grafana.example.com
You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=grafana.example.com
IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/grafana.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/grafana.example.com/privkey.pem Your cert will expire on 2022-05-07. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the “certonly” option. To non-interactively renew all of your certificates, run “certbot renew”
Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal.
If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
## 結論 おめでとうございます!Ubuntu 22.04にNginxをリバースプロキシとして使用し、Let's Encrypt SSLを使用してGrafana 8を正常にインストールしました。これで、Grafanaに外部データソースを追加し、Grafanaダッシュボードからそれらを監視を開始できます。質問があればお気軽にお尋ねください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。