### Full Grafana Docker Setup Example Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker A comprehensive example demonstrating the creation of a persistent volume, starting Grafana with that volume, setting the server root URL, and pre-installing a plugin. ```bash # create a persistent volume for your data docker volume create grafana-storage # start grafana by using the above persistent storage # and defining environment variables docker run -d -p 3000:3000 --name=grafana \ --volume grafana-storage:/var/lib/grafana \ -e "GF_SERVER_ROOT_URL=http://my.grafana.server/" \ -e "GF_PLUGINS_PREINSTALL=grafana-clock-panel" \ grafana/grafana-enterprise ``` -------------------------------- ### Install Grafana Foundation SDK for Go Source: https://archive.grafana.com/docs/grafana/v12.0/observability-as-code/foundation-sdk Install the Grafana Foundation SDK package for Go using go get. ```go go get github.com/grafana/grafana-foundation-sdk/go@next+cog-v0.0.x ``` -------------------------------- ### Task 1: One Rule Setup for Each Team Example Source: https://archive.grafana.com/docs/grafana/v12.0/administration/data-source-management/teamlbac/create-teamlbac-rules This example outlines a common use case for LBAC policies, granting access to logs or metrics with specific labels for different teams. ```text Team A has a rule namespace="dev". Team B has a rule namespace="prod". ``` -------------------------------- ### Grafana Configuration File Example Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-grafana Example of a Grafana configuration file with various settings. ```ini [security] admin_user = admin [auth.google] client_secret = 0ldS3cretKey [plugin.grafana-image-renderer] rendering_ignore_https_errors = true [feature_toggles] enable = newNavigation ``` -------------------------------- ### Start Grafana Server with init.d Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/start-restart-grafana Use these commands to start the Grafana service and verify its status using init.d. ```bash sudo service grafana-server start ``` ```bash sudo service grafana-server status ``` -------------------------------- ### Configure Grafana to Start at Boot with systemd Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/start-restart-grafana Enable the Grafana server to automatically start when the system boots up. ```bash sudo systemctl enable grafana-server.service ``` -------------------------------- ### Install Grizzly CLI Source: https://archive.grafana.com/docs/grafana/v12.0/administration/migration-guide/manually-migrate-to-grafana-cloud Download and install the Grizzly binary. Adapt the OS and architecture as needed for your system. ```shell # download the binary (adapt os and arch as needed) $ curl -fSL -o "/usr/local/bin/grr" "https://github.com/grafana/grizzly/releases/download/v0.3.1/grr-linux-amd64" # make it executable $ chmod a+x "/usr/local/bin/grr" # have fun :) $ grr --help ``` -------------------------------- ### Check Docker Compose Installation Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker Verify if the Docker Compose tool is installed on your system. If not, refer to the installation guide. ```bash docker compose version ``` -------------------------------- ### Configure Grafana to Start at Boot with init.d Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/start-restart-grafana Configure the Grafana server to start automatically at boot time using init.d. ```bash sudo update-rc.d grafana-server defaults ``` -------------------------------- ### Example Decryption of a Support Bundle Source: https://archive.grafana.com/docs/grafana/v12.0/troubleshooting/support-bundles An example command demonstrating how to decrypt a support bundle with specific input and output files. ```bash age --decrypt -i key.txt -o data.tar.gz af6684b4-d613-4b31-9fc3-7cb579199bea.tar.gz.age ``` -------------------------------- ### Start Grafana Server with systemd Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/start-restart-grafana Use these commands to start the Grafana service and verify its status. ```bash sudo systemctl daemon-reload sudo systemctl start grafana-server ``` ```bash sudo systemctl status grafana-server ``` -------------------------------- ### Example API Call Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/apis Example of how to construct an API call to get a specific dashboard using the standardized path structure. ```APIDOC ## Example API Call For example, to get a dashboard defined as: ```json { "kind": "Dashboard", "apiVersion": "dashboard.grafana.app/v1beta1", "metadata": { "name": "production-overview", // This value IS used in the URL path "namespace": "default", "uid": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" // This value is NOT used in the URL path // ... other metadata }, "spec": { // ... dashboard spec } } ``` You would use the following API call: `GET /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards/production-overview` ``` -------------------------------- ### Example Response for Get Single User by ID Source: https://archive.grafana.com/docs/grafana/v12.0/http_api/user This is an example response for retrieving a single user by their ID, detailing user properties. ```json HTTP/1.1 200 { "id": "1", "email": "user@mygraf.com", "name": "admin", "login": "admin", "theme": "light", "orgId": 1, "isGrafanaAdmin": true, "isDisabled": true, "isExternal": false, "authLabels": [], "updatedAt": "2019-09-09T11:31:26+01:00", "createdAt": "2019-09-09T11:31:26+01:00", "avatarUrl": "" } ``` -------------------------------- ### Reload and Start Prometheus Service (Linux/macOS) Source: https://archive.grafana.com/docs/grafana/v12.0/getting-started/get-started-grafana-prometheus Reload systemd configuration, enable Prometheus to start on boot, and start the service. ```bash sudo systemctl daemon-reload sudo systemctl enable prometheus sudo systemctl start prometheus sudo systemctl status prometheus ``` -------------------------------- ### Start Prometheus Service Source: https://archive.grafana.com/docs/grafana/v12.0/getting-started/get-started-grafana-prometheus Run this command to start the Prometheus service, specifying the configuration file location. ```bash ./prometheus --config.file=./prometheus.yml ``` -------------------------------- ### Install Grafana OSS Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/debian Installs the latest open-source release of Grafana using APT. ```bash # Installs the latest OSS release: sudo apt-get install grafana ``` -------------------------------- ### Complete Example for Navigation Customization Source: https://archive.grafana.com/docs/grafana/v12.0/administration/plugin-management/customize-nav-bar This example demonstrates configuring both the entire app plugin placement and individual page placements within the Grafana configuration file. ```ini # Move the entire app to the Explore section [navigation.app_sections] org-example-app = explore 50 # Move specific pages to their own sections [navigation.app_standalone_pages] /a/org-example-app/metrics = dashboards 100 /a/org-example-app/logs = alerting 75 ``` -------------------------------- ### PostgreSQL Provisioning Example Source: https://archive.grafana.com/docs/grafana/v12.0/datasources/postgres/configure Use this YAML configuration to provision a PostgreSQL data source. Ensure parameters match the example, including quotation marks, and do not include the database name in the URL. ```yaml apiVersion: 1 datasources: - name: Postgres type: postgres url: localhost:5432 user: grafana secureJsonData: password: 'Password!' jsonData: database: grafana sslmode: 'disable' # disable/require/verify-ca/verify-full maxOpenConns: 100 maxIdleConns: 100 maxIdleConnsAuto: true connMaxLifetime: 14400 postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10 timescaledb: false ``` -------------------------------- ### Start Grafana Server from Command Line Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/windows Execute the Grafana server binary from the command line to start Grafana. This is a prerequisite for accessing Grafana in a browser. ```bash grafana-server.exe ``` -------------------------------- ### Install Plugins using Grafana Helm Chart Source: https://archive.grafana.com/docs/grafana/v12.0/administration/plugin-management Specify plugins to install within your Helm values file. This example shows how to install the Grafana OnCall App and the Redis data source plugin. ```yaml plugins: - https://grafana.com/api/plugins/grafana-oncall-app/versions/v1.9.0/download;grafana-oncall-app - redis-datasource ``` -------------------------------- ### Start Grafana server on Windows Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/start-restart-grafana Execute the Grafana binary from the bin directory to start the server on Windows. It's recommended to run this from the command line. ```powershell grafana.exe server ``` -------------------------------- ### Install Latest Plugin Version Source: https://archive.grafana.com/docs/grafana/v12.0/cli Installs the latest available version of a specified plugin. ```bash grafana cli plugins install ``` -------------------------------- ### Start Grafana server with standalone binaries Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/mac Start the Grafana server using the standalone binaries. Navigate to the extracted Grafana directory and run this command. ```bash ./bin/grafana server ``` -------------------------------- ### Example RBAC Configuration Source: https://archive.grafana.com/docs/grafana/v12.0/administration/roles-and-permissions/access-control/configure-rbac This example shows how to configure RBAC settings in the Grafana configuration file. Ensure that the `[rbac]` section is present and the desired options are set. ```bash [rbac] permission_cache = true ``` -------------------------------- ### Install Certbot using Snapd Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/set-up-https Installs Certbot using Snapd and creates a symbolic link to make it accessible. This command ensures that Certbot is installed in a way that is compatible with Let's Encrypt. ```bash sudo apt-get remove certbot sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot ``` -------------------------------- ### Manually Start Grafana Server Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/debian Starts the Grafana server manually using its binary. This action also creates the data directory. ```shell /usr/local/grafana/bin/grafana-server --homepath /usr/local/grafana ``` -------------------------------- ### Install Grafana OSS Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/redhat-rhel-fedora Install the open-source version of Grafana using the DNF package manager after configuring the repository. ```bash sudo dnf install grafana ``` -------------------------------- ### Install Grafana OSS using Zypper Source: https://archive.grafana.com/docs/grafana/v12.0//setup-grafana/installation/suse-opensuse Install the open-source version of Grafana using the `zypper` package manager after adding the Grafana repository. ```bash sudo zypper install grafana ``` -------------------------------- ### Example Vault Configuration for Local Testing Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-security/configure-database-encryption/integrate-with-hashicorp-vault An example configuration for connecting to a local 'vault server -dev' instance using HTTP. Remember to replace the placeholder token with your actual key. ```ini [keystore.vault] url = http://127.0.0.1:8200 # HTTP should only be used for local testing auth_method = token token = s.sAZLyI0r7sFLMPq6MWtoOhAN # replace with your key ``` -------------------------------- ### LDAP Server Configuration Example Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-security/configure-authentication/ldap An example of how to configure an LDAP server connection in the `ldap.toml` file, specifying the host, port, and SSL/TLS settings for a secure connection. ```toml [[servers]] # Ldap server host (specify multiple hosts space separated) host = "ldap.my_secure_remote_server.org" # Default port is 389 or 636 if use_ssl = true port = 636 # Set to true if LDAP server should use an encrypted TLS connection (either with STARTTLS or LDAPS) use_ssl = true # If set to true, use LDAP with STARTTLS instead of LDAPS start_tls = false ``` -------------------------------- ### Start Grafana service with Homebrew Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/mac Start the Grafana service using Homebrew. This command ensures Grafana runs in the background. ```bash brew services start grafana ``` -------------------------------- ### Example Request for Test Data Source Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/data_source This example shows how to structure a POST request to query the Test data source. Ensure the `datasource.uid` matches your data source's UID and adjust `stringInput` as needed for your specific data. ```http POST /api/ds/query HTTP/1.1 { "queries":[ { "refId":"A", "scenarioId":"csv_metric_values", "datasource":{ "uid":"PD8C576611E62080A" }, "format": "table", "maxDataPoints":1848, "intervalMs":200, "stringInput":"1,20,90,30,5,0" } ], "from":"now-5m", "to":"now" } ``` -------------------------------- ### Example Report Creation Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/reporting This is an example of a successful response after creating a report. It confirms the report was created and provides a message. ```http HTTP/1.1 200 OK { "id": 4, "message": "Report created" } ``` -------------------------------- ### Install Grafana RPM Package Manually Source: https://archive.grafana.com/docs/grafana/v12.0//setup-grafana/installation/suse-opensuse Install necessary dependencies and Grafana using `zypper` and `rpm` for manual installation. This method requires manual updates for new versions. ```bash sudo zypper install initscripts urw-fonts wget wget sudo rpm -Uvh ``` -------------------------------- ### List Installed Plugins Source: https://archive.grafana.com/docs/grafana/v12.0/cli Lists all plugins that are currently installed in Grafana. ```bash grafana cli plugins ls ``` -------------------------------- ### MSSQL Table Creation Example Source: https://archive.grafana.com/docs/grafana/v12.0/datasources/mssql/query-editor Example SQL statement for creating a table named 'event' with specific columns. ```sql CREATE TABLE [event] ( time_sec bigint, description nvarchar(100), tags nvarchar(100), ) ``` -------------------------------- ### Install Grafana Plugin using CLI Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/mac Use the Grafana CLI to install a plugin. This command requires specifying paths for configuration, home, and plugins, and is specific to Homebrew installations on Apple Silicon. ```bash /opt/homebrew/opt/grafana/bin/grafana cli --config /opt/homebrew/etc/grafana/grafana.ini --homepath /opt/homebrew/opt/grafana/share/grafana --pluginsDir "/opt/homebrew/var/lib/grafana/plugins" plugins install ``` -------------------------------- ### Log Analytics KQL query examples Source: https://archive.grafana.com/docs/grafana/v12.0/datasources/azure-monitor/template-variables Use KQL queries to return values for template variables. These examples show how to retrieve virtual machines, virtual machines with template variables, objects from the Perf table, and metric names from the Perf table. ```kusto workspace("myWorkspace").Heartbeat | distinct Computer ``` ```kusto workspace("$workspace").Heartbeat | distinct Computer ``` ```kusto workspace("$workspace").Perf | distinct ObjectName ``` ```kusto workspace("$workspace").Perf | where ObjectName == "$object" | distinct CounterName ``` -------------------------------- ### Install Grafana Foundation SDK for Python Source: https://archive.grafana.com/docs/grafana/v12.0/observability-as-code/foundation-sdk Install the Grafana Foundation SDK package for Python using pip. ```bash pip install grafana-foundation-sdk ``` -------------------------------- ### Create Report Request Example Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/reporting This example demonstrates how to create a new report using the POST /api/reports endpoint. It includes details for scheduling, dashboard selection, and output formats. ```http POST /api/reports HTTP/1.1 { "name": "Report 4", "recipients": "texample-report@grafana.com", "replyTo": "", "message": "Hello, please, find the report attached", "schedule": { "startDate": "2022-10-02T10:00:00+02:00", "endDate": "2022-11-02T20:00:00+02:00", "frequency": "daily", "intervalFrequency": "", "intervalAmount": 0, "workdaysOnly": true, "timeZone": "Europe/Warsaw" }, "options": { "orientation": "landscape", "layout": "grid" }, "enableDashboardUrl": true, "dashboards": [ { "dashboard": { "uid": "7MeksYbmk", }, "timeRange": { "from": "2022-08-08T15:00:00+02:00", "to": "2022-09-02T17:00:00+02:00" }, "reportVariables": { "variable1": "Value1" } } ], "formats": [ "pdf", "csv" ] } ``` -------------------------------- ### Install prerequisite packages for Grafana APT repository Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/debian Installs necessary packages for managing APT repositories and downloading files. ```bash sudo apt-get install -y apt-transport-https software-properties-common wget ``` -------------------------------- ### Example Private Key Format Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-security/configure-authentication/saml/configure-saml-signing-encryption This is an example of how the base64-encoded private key should be formatted when used in Grafana configuration. ```text -----BEGIN PRIVATE KEY----- ... ... -----END PRIVATE KEY----- ``` -------------------------------- ### Start Grafana with Bind Mount Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker Starts a Grafana container using a host directory for persistent storage. Requires the container to run with the host user's ID for proper permissions. ```bash # create a directory for your data mkdir data # start grafana with your user id and using the data directory docker run -d -p 3000:3000 --name=grafana \ --user "$(id -u)" \ --volume "$PWD/data:/var/lib/grafana" \ grafana/grafana-enterprise ``` -------------------------------- ### Install Plugin Source: https://archive.grafana.com/docs/grafana/v12.0/cli Installs a plugin from the Grafana default repositories. You can install the latest version or a specific version. ```APIDOC ## Install Plugin ### Description Installs a plugin from the Grafana default repositories. ### Command `plugins install [version]` ### Parameters - **plugin-id** (string) - Required - The ID of the plugin to install. - **version** (string) - Optional - The specific version of the plugin to install. ### Example (Latest Version) ```bash grafana cli plugins install ``` ### Example (Specific Version) ```bash grafana cli plugins install ``` ``` -------------------------------- ### Basic Table Data Example Source: https://archive.grafana.com/docs/grafana/v12.0/panels-visualizations/visualizations/table This example demonstrates a complete dataset for a table visualization where every cell has data. ```csv Column1, Column2, Column3 value1 , value2 , value3 value4 , value5 , value6 value7 , value8 , value9 ``` -------------------------------- ### Example Response for User Lookup Source: https://archive.grafana.com/docs/grafana/v12.0/http_api/user An example response when looking up a user by their login or email, returning the user's profile information. ```json HTTP/1.1 200 { "id": 1, "email": "user@mygraf.com", "name": "admin", "login": "admin", "theme": "light", "orgId": 1, "isGrafanaAdmin": true, "isDisabled": false, "isExternal": false, "authLabels": null, "updatedAt": "2019-09-25T14:44:37+01:00", "createdAt": "2019-09-25T14:44:37+01:00", "avatarUrl":"" } ``` -------------------------------- ### List Installed Plugins Source: https://archive.grafana.com/docs/grafana/v12.0/cli Lists all plugins that are currently installed in Grafana. ```APIDOC ## List Installed Plugins ### Description Lists all currently installed plugins. ### Command `plugins ls` ### Example ```bash grafana cli plugins ls ``` ``` -------------------------------- ### Example Response for User Search Source: https://archive.grafana.com/docs/grafana/v12.0/http_api/user This is an example response for the user search endpoint, showing total count, user details, and pagination information. ```json HTTP/1.1 200 { "totalCount": 2, "users": [ { "id": 1, "name": "Admin", "login": "admin", "email": "admin@mygraf.com", "isAdmin": true, "isDisabled": false, "lastSeenAt": "2020-04-10T20:29:27+03:00", "lastSeenAtAge': "2m", "authLabels": ["OAuth"] }, { "id": 2, "name": "User", "login": "user", "email": "user@mygraf.com", "isAdmin": false, "isDisabled": false, "lastSeenAt": "2020-01-24T12:38:47+02:00", "lastSeenAtAge": "2M", "authLabels": [] } ], "page": 1, "perPage": 10 } ``` -------------------------------- ### Install Specific Plugin Version Source: https://archive.grafana.com/docs/grafana/v12.0/cli Installs a specific version of a plugin by providing both the plugin ID and the version number. ```bash grafana cli plugins install ``` -------------------------------- ### Install Plugin from Custom Repository Source: https://archive.grafana.com/docs/grafana/v12.0/cli Use the `--repo` option to specify a custom repository URL for downloading and installing or updating plugins, instead of using the default Grafana repository. ```bash grafana cli --repo "https://example.com/plugins" plugins install ``` -------------------------------- ### Example GitLab configuration in Grafana Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-security/configure-authentication/gitlab Complete example of GitLab authentication configuration in Grafana's configuration file. Includes client ID, secret, scopes, and role/group mapping settings. ```bash [auth.gitlab] enabled = true allow_sign_up = false auto_login = false client_id = YOUR_GITLAB_APPLICATION_ID client_secret = YOUR_GITLAB_APPLICATION_SECRET scopes = openid email profile auth_url = https://gitlab.com/oauth/authorize token_url = https://gitlab.com/oauth/token api_url = https://gitlab.com/api/v4 role_attribute_path = contains(groups[*], 'example-group') && 'Editor' || 'Viewer' role_attribute_strict = false allow_assign_grafana_admin = false allowed_groups = ["admins", "software engineers", "developers/frontend"] allowed_domains = mycompany.com mycompany.org tls_skip_verify_insecure = false use_pkce = true use_refresh_token = true ``` -------------------------------- ### Install Grafana Foundation SDK for TypeScript (yarn) Source: https://archive.grafana.com/docs/grafana/v12.0/observability-as-code/foundation-sdk Install the Grafana Foundation SDK package for TypeScript using yarn. ```bash yarn add @grafana/grafana-foundation-sdk ``` -------------------------------- ### Example Report Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/reporting This is an example of a successful response when retrieving report details. It includes information about the report's configuration, schedule, and associated dashboards. ```json HTTP/1.1 200 OK { "id": 2, "userId": 1, "orgId": 1, "name": "Report 2", "recipients": "example-report@grafana.com", "replyTo": "", "message": "Hi, \nPlease find attached a PDF status report. If you have any questions, feel free to contact me!\nBest,", "schedule": { "startDate": "2022-10-02T00:00:00+02:00", "endDate": null, "frequency": "once", "intervalFrequency": "", "intervalAmount": 0, "workdaysOnly": false, "dayOfMonth": "2", "timeZone": "Europe/Warsaw" }, "options": { "orientation": "landscape", "layout": "grid", }, "enableDashboardUrl": true, "state": "scheduled", "dashboards": [ { "dashboard": { "id": 463, "uid": "7MeksYbmk", "name": "Alerting with TestData" }, "timeRange": { "from": "", "to": "" }, "reportVariables": { "namefilter": "TestData" } } ], "formats": [ "pdf", "csv" ], "created": "2022-09-12T11:44:42+02:00", "updated": "2022-09-12T11:44:42+02:00" } ``` -------------------------------- ### Example Response for Contact Points Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/alerting_provisioning An example of the JSON response when retrieving all contact points, showing their structure and settings. ```json HTTP/1.1 200 OK [ { "uid": "", "name": "email receiver", "type": "email", "settings": { "addresses": "" }, "disableResolveMessage": false } ] ``` -------------------------------- ### Install Grafana Foundation SDK for TypeScript (npm) Source: https://archive.grafana.com/docs/grafana/v12.0/observability-as-code/foundation-sdk Install the Grafana Foundation SDK package for TypeScript using npm. ```bash npm install @grafana/grafana-foundation-sdk ``` -------------------------------- ### Get Home Dashboard API Request Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/dashboard Use this endpoint to retrieve the home dashboard configuration. No specific setup is required beyond making the HTTP GET request. ```http GET /api/dashboards/home HTTP/1.1 ``` -------------------------------- ### Install Plugin with Custom Plugin Directory Source: https://archive.grafana.com/docs/grafana/v12.0/cli Override the default plugin directory using the `--pluginsDir` option to install, update, or remove plugins from a specified location. This is useful for development or custom setups. ```bash grafana cli --pluginsDir "/var/lib/grafana/devplugins" plugins install ``` -------------------------------- ### Get Team Members API Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/team Example response when retrieving team members, showing user details for each member. ```json HTTP/1.1 200 [ { "orgId": 1, "teamId": 1, "userId": 3, "email": "user1@email.com", "login": "user1", "avatarUrl": "\/avatar\/1b3c32f6386b0185c40d359cdc733a79" }, { "orgId": 1, "teamId": 1, "userId": 2, "email": "user2@email.com", "login": "user2", "avatarUrl": "\/avatar\/cad3c68da76e45d10269e8ef02f8e73e" } ] ``` -------------------------------- ### Get All Correlations Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/correlations Example response listing all correlations in the system. This response can be paginated and filtered using query parameters. ```json HTTP/1.1 200 [ { "description": "Prometheus to Loki", "label": "My Label", "sourceUID": "uyBf2637k", "targetUID": "PDDA8E780A17E7EF1", "uid": "J6gn7d31L", "provisioned": false, "type": "query", "config": { "field": "message", "target": {}, } }, { "description": "Loki to Tempo", "label": "Another Label", "sourceUID": "PDDA8E780A17E7EF1", "targetUID": "P15396BDD62B2BE29", "uid": "uWCpURgVk", "provisioned": false, "type": "query", "config": { "field": "message", "target": {}, } } ] ``` -------------------------------- ### Basic Search API Call (Anonymous Access) Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/examples/curl-examples This is the most basic example for a dashboard with no authentication. It assumes a default installation with anonymous access enabled. ```APIDOC ## GET /api/search ### Description Retrieves a list of dashboards. This example assumes anonymous access is enabled. ### Method GET ### Endpoint http://localhost:3000/api/search ``` -------------------------------- ### Get Team Preferences API Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/team Example response when retrieving team preferences, showing theme, home dashboard, and timezone settings. ```json HTTP/1.1 200 { "theme": "", "homeDashboardId": 0, "timezone": "" } ``` -------------------------------- ### Example Grafana Docker Compose with Plugins and Volumes Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker An example docker-compose.yaml configuration for Grafana, including pre-installed plugins, environment variables for root URL, and a named Docker volume for storage. ```yaml services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped environment: - GF_SERVER_ROOT_URL=http://my.grafana.server/ - GF_PLUGINS_PREINSTALL=grafana-clock-panel ports: - '3000:3000' volumes: - 'grafana_storage:/var/lib/grafana' volumes: grafana_storage: {} ``` -------------------------------- ### Install Font Packages for Server-Side Image Rendering Source: https://archive.grafana.com/docs/grafana/v12.0/troubleshooting If text is missing in server-side rendered images on RPM-based Linux systems, install these font packages. ```bash sudo yum install fontconfig sudo yum install freetype* sudo yum install urw-fonts ``` -------------------------------- ### LogQL Example for LBAC Rule Source: https://archive.grafana.com/docs/grafana/v12.0/administration/data-source-management/teamlbac/create-teamlbac-rules This example demonstrates a LogQL query used as an LBAC rule to filter log lines matching specific labels. ```logql {namespace="dev", cluster="us-west-0"} ``` -------------------------------- ### Get all dashboard versions by dashboard UID Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/dashboard_versions Retrieves all existing dashboard versions for a given dashboard UID. Supports pagination with `limit` and `start` query parameters. ```APIDOC ## GET /api/dashboards/uid/:uid/versions ### Description Gets all existing dashboard versions for the dashboard with the given `uid`. ### Method GET ### Endpoint `/api/dashboards/uid/:uid/versions` ### Parameters #### Query Parameters - **limit** (integer) - Optional - Maximum number of results to return - **start** (integer) - Optional - Version to start from when returning queries ### Request Example ```http GET /api/dashboards/uid/QA7wKklGz/versions?limit=2?start=0 HTTP/1.1 ``` ### Response #### Success Response (200) - **versions** (array) - List of dashboard versions - **totalVersions** (integer) - Total number of versions available #### Response Example ```json { "versions": [ { "id": 1, "uid": "QA7wKklGz", "dashboardId": 1, "parentVersion": 0, "restoredFrom": null, "version": 1, "created": "2023-01-01T10:00:00Z", "createdBy": "admin", "message": "Initial version" } ], "totalVersions": 5 } ``` ### Status Codes - **200** - Ok - **400** - Errors - **401** - Unauthorized - **404** - Dashboard version not found ``` -------------------------------- ### Get All Correlations from Data Source Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/correlations Example response containing a list of correlations originating from a particular data source. Each item includes correlation details. ```json HTTP/1.1 200 [ { "description": "Logs to Traces", "label": "My Label", "sourceUID": "uyBf2637k", "targetUID": "PDDA8E780A17E7EF1", "uid": "J6gn7d31L", "provisioned": false, "type": "query", "config": { "field": "message", "target": {}, } }, { "description": "Logs to Metrics", "label": "Another Label", "sourceUID": "uyBf2637k", "targetUID": "P15396BDD62B2BE29", "uid": "uWCpURgVk", "provisioned": false, "type": "query", "config": { "field": "message", "target": {}, } } ] ``` -------------------------------- ### Example RBAC Provisioning Configuration File Source: https://archive.grafana.com/docs/grafana/v12.0/administration/roles-and-permissions/access-control/rbac-grafana-provisioning This YAML file demonstrates how to provision RBAC settings in Grafana. It includes examples for creating custom roles, deleting custom roles, updating basic role permissions, assigning roles to teams, and revoking role assignments from teams. ```yaml --- # config file version apiVersion: 2 ``` -------------------------------- ### Example Response for Mute Timings Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/alerting_provisioning An example response for retrieving mute timings, illustrating the structure for defining time intervals and weekdays. ```json HTTP/1.1 200 OK [ { "name": "weekends", "time_intervals": [ { "weekdays": [ "saturday", "sunday" ] } ], "version": "", "provenance": "file" } ] ``` -------------------------------- ### Get Single Correlation Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/correlations Example of a successful response when retrieving a single data source correlation. It includes details like description, label, source and target UIDs, and configuration. ```json HTTP/1.1 200 { "description": "Logs to Traces", "label": "My Label", "sourceUID": "uyBf2637k", "targetUID": "PDDA8E780A17E7EF1", "uid": "J6gn7d31L", "provisioned": false, "type": "query", "config": { "field": "message", "target": {}, } } ``` -------------------------------- ### Get all dashboard versions by dashboard UID Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/dashboard_versions Retrieves all historical versions of a specific dashboard using its unique identifier (UID). Supports limiting the number of results and specifying a starting version for pagination. ```http GET /api/dashboards/uid/QA7wKklGz/versions?limit=2?start=0 HTTP/1.1 ``` -------------------------------- ### Map Instance to Environment Label Source: https://archive.grafana.com/docs/grafana/v12.0/alerting/best-practices/dynamic-labels Use a known label value to enrich alerts with additional metadata. This example maps the `instance` label to an `env` label representing the deployment environment. ```go {{- if eq $labels.instance "prod-server-1" -}}production{{- else if eq $labels.instance "stag-server-1" -}}staging{{- else -}}development{{- end -}} ``` -------------------------------- ### Example Response for Root Level Search Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/folder_dashboard_search This is an example of the JSON response when retrieving folders and dashboards at the root level. It includes details like ID, UID, title, URL, type, and tags for each item. ```json HTTP/1.1 200 [ { "id": 163, "uid": "000000163", "orgId": 1, "title": "Folder", "url": "/dashboards/f/000000163/folder", "type": "dash-folder", "tags": [], "isStarred": false, "uri":"db/folder" // deprecated in Grafana v5.0 }, { "id":1, "uid": "cIBgcSjkk", "orgId": 1, "title":"Production Overview", "url": "/d/cIBgcSjkk/production-overview", "type":"dash-db", "tags":[prod], "isStarred":true, "uri":"db/production-overview" // deprecated in Grafana v5.0 } ] ``` -------------------------------- ### Install Snapd for Certbot Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/set-up-https Installs Snapd, a package manager for running Certbot, on Debian-based systems. This is a prerequisite for installing and managing Let's Encrypt certificates. ```bash sudo apt-get install snapd sudo snap install core; sudo snap refresh core ``` -------------------------------- ### Start Grafana with Docker Volume Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker Starts a Grafana container using a pre-created Docker volume for persistent storage. Ensures data is not lost when the container is removed. ```bash # start grafana docker run -d -p 3000:3000 --name=grafana \ --volume grafana-storage:/var/lib/grafana \ grafana/grafana-enterprise ``` -------------------------------- ### Install Plugin from Custom URL in Docker Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker Installs a plugin from a custom URL during Grafana container startup. The format is @[]@. ```bash docker run -d -p 3000:3000 --name=grafana \ -e "GF_PLUGINS_PREINSTALL=custom-plugin@@https://github.com/VolkovLabs/custom-plugin.zip" \ grafana/grafana-enterprise ``` -------------------------------- ### Create Library Element Response Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/library_element Example response after successfully creating a library element. It includes the element's ID, UID, version, and metadata. ```json HTTP/1.1 200 { "result": { "id": 28, "orgId": 1, "folderId": 0, "folderUid": "", "uid": "nErXDvCkzz", "name": "Example library panel", "kind": 1, "type": "", "description": "", "model": {...}, "version": 1, "meta": { "folderName": "General", "folderUid": "", "connectedDashboards": 0, "created": "2021-09-30T09:14:22.378307+02:00", "updated": "2021-09-30T09:14:22.378307+02:00", "createdBy": { "id": 1, "name": "admin", "avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56" }, "updatedBy": { "id": 1, "name": "admin", "avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56" } } } } ``` -------------------------------- ### Update All Installed Plugins Source: https://archive.grafana.com/docs/grafana/v12.0/cli Updates all installed plugins to their latest available versions. ```bash grafana cli plugins update-all ``` -------------------------------- ### Dry Run Success Output Example Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/kubernetes Example output when a 'kubectl apply --dry-run=server' command completes successfully, indicating no changes were made but the operation would have succeeded. ```bash persistentvolumeclaim/grafana-pvc unchanged (server dry run) deployment.apps/grafana unchanged (server dry run) service/grafana unchanged (server dry run) ``` -------------------------------- ### Install Grafana plugins using Helm Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/helm Configure the `plugins` section in your `values.yaml` file to install desired plugins, such as the Zabbix app or Clock panel, when deploying Grafana via Helm. ```yaml ....... ............ ...... plugins: # here we are installing two plugins, make sure to keep the indentation correct as written here. - alexanderzobnin-zabbix-app - grafana-clock-panel ....... ............ ...... ``` -------------------------------- ### File Provider for Variable Expansion Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-grafana Example of using the 'file' provider to read configuration values from a file. ```ini [database] password = $__file{/etc/secrets/gf_sql_password} ``` -------------------------------- ### Example Output for $value with Single Data Source Source: https://archive.grafana.com/docs/grafana/v12.0/alerting/alerting-rules/templates/reference Demonstrates the simplified output of the $value variable when only a single data source is used. ```go template 81.234: CPU usage has exceeded 80% for the last 5 minutes. ``` -------------------------------- ### Enable Grafana Tracing Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-grafana/configure-tracing Start the Grafana server with tracing enabled. Specify a custom file path for the trace output. ```bash ./grafana server -tracing -tracing-file=/tmp/trace.out ``` -------------------------------- ### Get All Roles Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/access_control Gets all existing roles, including global and organization-specific custom roles. ```APIDOC ## GET /api/access-control/roles ### Description Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in. ### Method GET ### Endpoint /api/access-control/roles ### Query Parameters - `includeHidden` (boolean) - Optional. Set to `true` to include roles that are `hidden`. ### Required Permissions - Action: `roles:read` - Scope: `roles:*` ### Request Example ```http GET /api/access-control/roles ``` ### Response #### Success Response (200) - Global and organization local roles are returned. #### Response Example ```http HTTP/1.1 200 OK ``` #### Status Codes - **200**: Global and organization local roles are returned. - **403**: Access denied. - **500**: Unexpected error. Refer to body and/or server logs for more details. ``` -------------------------------- ### Install Grafana Enterprise using Zypper Source: https://archive.grafana.com/docs/grafana/v12.0//setup-grafana/installation/suse-opensuse Install the Grafana Enterprise version using the `zypper` package manager after adding the Grafana repository. This version includes additional features that can be unlocked with a license. ```bash sudo zypper install grafana-enterprise ``` -------------------------------- ### Example Dashboard API Call Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/apis This example shows how to construct an API call to retrieve a specific dashboard using its name. The name segment in the URL path corresponds to the metadata.name field of the resource. ```http GET /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards/production-overview ``` -------------------------------- ### Basic Authentication Example Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api Demonstrates how to authenticate HTTP API requests using basic authentication with a username and password. ```APIDOC ## Basic Auth If basic auth is enabled (it is enabled by default), then you can authenticate your HTTP request via standard basic auth. Basic auth will also authenticate LDAP users. ### Example ```bash curl http://admin:admin@localhost:3000/api/org ``` ### Response Example ```json { "id": 1, "name": "Main Org." } ``` ``` -------------------------------- ### Upload JSON Trace File Example Source: https://archive.grafana.com/docs/grafana/v12.0/datasources/jaeger Example of a JSON structure representing a single trace that can be uploaded to Grafana for visualization. If the file contains multiple traces, only the first one will be displayed. ```json { "data": [ { "traceID": "2ee9739529395e31", "spans": [ { "traceID": "2ee9739529395e31", "spanID": "2ee9739529395e31", "flags": 1, "operationName": "CAS", "references": [], "startTime": 1616095319593196, "duration": 1004, "tags": [ { "key": "sampler.type", "type": "string", "value": "const" } ], "logs": [], "processID": "p1", "warnings": null } ], "processes": { "p1": { "serviceName": "loki-all", "tags": [ { "key": "jaeger.version", "type": "string", "value": "Go-2.25.0" } ] } }, "warnings": null } ], "total": 0, "limit": 0, "offset": 0, "errors": null } ``` -------------------------------- ### Example Output for $values Source: https://archive.grafana.com/docs/grafana/v12.0/alerting/alerting-rules/templates/reference Illustrates the rendered output of a template using $values.A.Value with specific alert labels and query results. ```go template 81.2345 CPU usage for instance1 over the last 5 minutes. ``` -------------------------------- ### List Role Permissions with HTTP Basic Authorization Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/examples/curl-examples This example demonstrates how to list permissions associated with roles using HTTP basic authorization. Ensure your username and password are correctly encoded. ```bash curl --location '/api/access-control/builtin-roles' --user 'user:password' ``` -------------------------------- ### Analyze CPU Profile with pprof Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-grafana/configure-tracing Use the `go tool pprof` command to analyze a collected CPU profile. This helps identify performance bottlenecks. ```bash go tool pprof -http=localhost:8081 profile.pprof ``` -------------------------------- ### Example JWT Authentication URL Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/configure-security/configure-authentication/jwt An example of how to construct a Grafana URL with a JWT embedded in the `auth_token` query parameter. ```http http://env.grafana.local/d/RciOKLR4z/board-identifier?orgId=1&kiosk&auth_token=eyJhbxxxxxxxxxxxxx ``` -------------------------------- ### Install Grafana Helm Chart Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/helm Deploy the Grafana Helm chart into the specified namespace. Replace `my-grafana` with your desired logical chart name. ```bash helm install my-grafana grafana/grafana --namespace monitoring ``` -------------------------------- ### Graphite Example Queries Source: https://archive.grafana.com/docs/grafana/v12.0/dashboards/variables/add-template-variables Illustrates potential query outcomes for CPU metrics based on user selections of application and server. Supports single and multiple server selections. ```text apps.backend.backend_01.cpu.* ``` ```text apps.{backend.backend_02,backend_03}.cpu.* ``` ```text apps.fakesite.web_server_01.cpu.* ``` -------------------------------- ### Create Grafana YAML Manifest Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/kubernetes Initializes the grafana.yaml file which will contain the Kubernetes resource definitions. ```bash touch grafana.yaml ``` -------------------------------- ### Create docker-compose.yaml File Source: https://archive.grafana.com/docs/grafana/v12.0/setup-grafana/installation/docker Prepare the directory and create an empty docker-compose.yaml file for Grafana configuration. ```bash # first go into the directory where you have created this docker-compose.yaml file cd /path/to/docker-compose-directory # now create the docker-compose.yaml file touch docker-compose.yaml ``` -------------------------------- ### MSSQL Macro Examples Source: https://archive.grafana.com/docs/grafana/v12.0/datasources/mssql/query-editor Examples of various macros available in the MSSQL query editor for time series and filtering. ```sql dateColumn AS time ``` ```sql DATEDIFF(second, '1970-01-01', dateColumn) AS time ``` ```sql dateColumn BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:06:17Z' ``` ```sql '2017-04-21T05:01:17Z' ``` ```sql '2017-04-21T05:06:17Z' ``` ```sql CAST(ROUND(DATEDIFF(second, '1970-01-01', time_column)/300.0, 0) AS bigint) * 300 ``` ```sql CAST(ROUND(DATEDIFF(second, '1970-01-01', time_column)/300.0, 0) AS bigint) * 300 ``` ```sql CAST(ROUND(DATEDIFF(second, '1970-01-01', time_column)/300.0, 0) AS bigint) * 300 ``` ```sql CAST(ROUND(DATEDIFF(second, '1970-01-01', time_column)/300.0, 0) AS bigint) * 300 ``` ```sql dateColumn > 1494410783 AND dateColumn < 1494497183 ``` ```sql 1494410783 ``` ```sql 1494497183 ``` ```sql dateColumn > 1494410783152415214 AND dateColumn < 1494497183142514872 ``` ```sql 1494410783152415214 ``` ```sql 1494497183142514872 ``` ```sql $__unixEpochGroup(dateColumn, '5m', [fillMode]) ``` ```sql $__unixEpochGroupAlias(dateColumn, '5m', [fillMode]) ``` -------------------------------- ### Get Reports Branding Settings Request Source: https://archive.grafana.com/docs/grafana/v12.0/developers/http_api/reporting Send a GET request to retrieve the global reports branding settings. ```http GET /api/reports/settings HTTP/1.1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.