Grafana Dashboard Server

Sets up Grafana server for data visualization and monitoring dashboards

Script Author

Rowan de Haas's avatar
Rowan de Haas
Script Author

Script Details

Created 11 months ago
Size 2 KB

Tags

Script Content

Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#cloud-config
package_update: true
package_upgrade: true

packages:
  - wget
  - gnupg
  - software-properties-common
  - apt-transport-https

write_files:
  - path: /etc/grafana/grafana.ini
    content: |
      [server]
      protocol = http
      http_addr = 0.0.0.0
      http_port = 3000
      domain = localhost
      
      [security]
      admin_user = admin
      admin_password = SecureGrafanaPassword123!
      
      [users]
      allow_sign_up = false
      allow_org_create = false
      
      [auth.anonymous]
      enabled = false
      
      [logging]
      mode = file
      level = info
    permissions: '0644'
    owner: grafana:grafana

runcmd:
  # Add Grafana GPG key
  - wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
  # Add Grafana repository
  - echo "deb https://packages.grafana.com/oss/deb stable main" | tee /etc/apt/sources.list.d/grafana.list
  # Update and install Grafana
  - apt-get update
  - apt-get install -y grafana
  # Enable and start Grafana
  - systemctl enable grafana-server
  - systemctl start grafana-server
  # Configure firewall
  - ufw allow 3000/tcp
  # Wait for startup
  - sleep 15
  - systemctl status grafana-server

How to Use This Script

Cloud Provider Examples

Amazon EC2

aws ec2 run-instances
  --image-id ami-12345678
  --instance-type t3.micro
  --user-data file://script.yaml

DigitalOcean

doctl compute droplet create
  --image ubuntu-22-04-x64
  --size s-1vcpu-1gb
  --user-data-file script.yaml
  my-droplet

Google Cloud

gcloud compute instances create
  my-instance
  --metadata-from-file
  user-data=script.yaml