Last active
April 15, 2020 08:23
-
-
Save danpawlik/967cc307cc76d06ae8432e331d4f0adb to your computer and use it in GitHub Desktop.
Script for deploying grafana on Centos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat << EOF | sudo tee /etc/yum.repos.d/grafana.repo | |
[grafana] | |
name=grafana | |
baseurl=https://packages.grafana.com/oss/rpm | |
repo_gpgcheck=1 | |
enabled=1 | |
gpgcheck=1 | |
gpgkey=https://packages.grafana.com/gpg.key | |
sslverify=1 | |
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |
EOF | |
sudo yum install -y grafana | |
sudo systemctl daemon-reload | |
sudo systemctl start grafana-server | |
sudo systemctl status grafana-server | |
# configure prometheus dashboards | |
curl https://grafana.com/api/dashboards/1860/revisions/16/download > /etc/grafana/provisioning/dashboards/node_exporter_full.json | |
curl https://grafana.com/api/dashboards/8010/revisions/1/download > /etc/grafana/provisioning/dashboards/alert_manager.json | |
curl https://grafana.com/api/dashboards/7587/revisions/3/download > /etc/grafana/provisioning/dashboards/blackbox.json | |
# integrate grafana with prometheus | |
cat << EOF | sudo tee /etc/grafana/provisioning/datasources/datasource_prometheus.yml | |
apiVersion: 1 | |
datasources: | |
- access: 'proxy' | |
editable: true | |
isDefault: true | |
name: 'prometheus' | |
orgId: 1 | |
type: 'prometheus' | |
url: 'http://localhost:9090' | |
EOF | |
cat << EOF | sudo tee /etc/grafana/provisioning/dashboards/dashboards.yml | |
apiVersion: 1 | |
providers: | |
- name: 'default' | |
orgId: 1 | |
folder: '' | |
folderUid: '' | |
type: file | |
disableDeletion: true | |
editable: false | |
updateIntervalSeconds: 10 | |
allowUiUpdates: false | |
options: | |
path: /etc/grafana/provisioning/dashboards/ | |
EOF | |
host=$(hostname -I | tr -d "[:blank:]") | |
cat << EOF | sudo tee /etc/grafana/grafana.ini | |
[paths] | |
[server] | |
root_url = http://$host:3000/ | |
[database] | |
[remote_cache] | |
[dataproxy] | |
[analytics] | |
[security] | |
[snapshots] | |
[dashboards] | |
[users] | |
[auth] | |
[auth.anonymous] | |
enabled = true | |
org_role = Viewer | |
[auth.github] | |
[auth.google] | |
[auth.generic_oauth] | |
[auth.saml] | |
[auth.grafana_com] | |
[auth.proxy] | |
[auth.basic] | |
[auth.ldap] | |
[smtp] | |
[emails] | |
[log] | |
[log.console] | |
[log.file] | |
[log.syslog] | |
[alerting] | |
[explore] | |
[metrics] | |
[metrics.graphite] | |
[tracing.jaeger] | |
[grafana_com] | |
[external_image_storage] | |
[external_image_storage.s3] | |
[external_image_storage.webdav] | |
[external_image_storage.gcs] | |
[external_image_storage.azure_blob] | |
[external_image_storage.local] | |
[rendering] | |
[enterprise] | |
[panels] | |
[plugins] | |
EOF | |
sudo systemctl restart grafana-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment