### Start Mail-House Example with Docker Compose Source: https://grafana.com/docs/grafana-cloud/connect-externally-hosted/data-sources/loki/logcli/logcli-tutorial Start the mail-house example using Docker Compose. This command launches the necessary services, including Loki and Grafana, for the tutorial. ```bash docker compose -f alloy-scenarios/mail-house/docker-compose.yml up -d ``` -------------------------------- ### Deploy Docker Compose Example Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/monitor/monitor-logs-from-file Navigate to the log file example directory and start the Docker containers for the Grafana stack. Ensure Docker is running before executing this command. ```shell cd alloy-scenarios/logs-file docker compose up -d ``` -------------------------------- ### Template Output Example Source: https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/configure-notifications/template-notifications/reference This example shows the expected output from the Go template snippet above, demonstrating the formatted alert start times with timezone information. ```template-output 2024-10-30 21:01:45.227 +0100 CET 21:01:45 CET ``` -------------------------------- ### Install Foundation SDK for Go Source: https://grafana.com/docs/grafana-cloud/as-code/observability-as-code/foundation-sdk Install the Grafana Foundation SDK for Go using the go get command. Ensure you are using the latest version. ```go go get github.com/grafana/grafana-foundation-sdk/go@latest ``` -------------------------------- ### Example: Find and Index Metrics Source: https://grafana.com/docs/grafana-cloud/cost-management-and-billing/analyze-costs/metrics-costs/graphite-metrics-costs An example of using `walk_metrics.py` to find metrics starting from a specific URL and user credentials, then saving the output to a file. It also shows how to sort the output. ```bash walk_tree.py \ --url https://graphite-us-central1.grafana.net/graphite \ --user \ --password \ --from=-1w \ | tee metrics-index.txt # Optionally: sort metrics-index.txt > metrics-index-sorted.txt ``` -------------------------------- ### Deploy Docker monitoring example Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/monitor/monitor-docker-containers Navigate to the docker-monitoring directory and start the Grafana stack using Docker Compose. ```shell cd alloy-scenarios/docker-monitoring docker compose up -d ``` -------------------------------- ### Verify pg_stat_statements Extension Source: https://grafana.com/docs/grafana-cloud/monitor-applications/database-observability/troubleshoot/postgres Check if the `pg_stat_statements` extension is installed in the current database. If missing, refer to the setup guide to enable it. ```sql SELECT * FROM pg_extension WHERE extname = 'pg_stat_statements'; ``` -------------------------------- ### Create alloy-tutorial directory and docker-compose.yml file Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/tutorials/send-logs-to-loki Creates a directory for the tutorial and an empty docker-compose.yml file. ```bash mkdir alloy-tutorial cd alloy-tutorial touch docker-compose.yml ``` -------------------------------- ### Install Traces Drilldown Plugin in Docker Container Source: https://grafana.com/docs/grafana-cloud/visualizations/simplified-exploration/traces/access Configure this environment variable within your Docker setup to automatically install the Traces Drilldown plugin when the container starts. This is useful for containerized Grafana deployments. ```shell GF_INSTALL_PLUGINS=grafana-exploretraces-app ``` -------------------------------- ### Example of time.Now function Source: https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/configure-notifications/template-notifications/reference Shows how to use the `time.Now` function to get the current time in UTC and local formats, and to calculate the duration since an alert started. ```go {{ define "time.example" }} {{- /* Get current time in different formats */ -}} Current Time (UTC): {{ (time.Now).UTC.Format "2006-01-02 15:04:05 MST" }} Current Time (Local): {{ (time.Now).Format "Monday, January 2, 2006 at 15:04:05" }} {{- /* Compare alert time with current time */ -}} {{ $timeAgo := (time.Now).Sub .StartsAt }} Alert fired: {{ $timeAgo }} ago {{ end }} ``` ```none Current Time (UTC): 2025-03-08 18:14:27 UTC Current Time (Local): Saturday, March 8, 2025 at 14:14:27 Alert fired: 25h49m32.78574723s ago ``` -------------------------------- ### Example k6 Extension Provisioning Output Source: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/use-k6-extensions This output indicates that k6 has successfully provisioned a new binary that includes the specified extensions. ```text INFO[0287] A new k6 binary has been provisioned with version(s): k6:v1.1.0 k6/x/faker:v0.4.4 ``` -------------------------------- ### Get Installed Plugin Information Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api Retrieve details about a specific plugin installed on your Grafana Cloud Stack using this HTTP GET request. ```http GET https://grafana.com/api/instances//plugins/ ``` -------------------------------- ### Example GET Request for Metrics Summary API Source: https://grafana.com/docs/grafana-cloud/send-data/traces/configure/metrics-summary-api An example GET request to the Metrics Summary API endpoint. Replace the placeholder URL with your actual Grafana Cloud Tempo URL. ```none GET https://tempo-dedicated-02-prod-us-central-0.grafana.net/tempo/api/metrics/summary ``` -------------------------------- ### Example Metric Configuration Source: https://grafana.com/docs/grafana-cloud/knowledge-graph/get-started/manage-datasets This example shows a metric with environment and cluster labels. If a special 'environment' label is not used, 'cluster' can serve as the environment label. ```none http_server_duration_bucket{cluster="company-abc-infra-dev-euw2-eu-west-2-eks",environment="dev",,container="support",instance="XXX.XX.XX.XXX:8000",job="support-support-svc-metrics",le="5",namespace="support", service="support-support-svc-metrics"} ``` -------------------------------- ### Install grafanactl from Source Source: https://grafana.com/docs/grafana-cloud/as-code/observability-as-code/grafana-cli/grafanactl Build the grafanactl CLI from source using Go. Ensure you have git and Go v1.24 or greater installed. ```bash go install github.com/grafana/grafanactl/cmd/grafanactl@latest ``` -------------------------------- ### Get Dashboard Example Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/apis Example of how to retrieve a specific dashboard using its namespace and name. ```APIDOC ## GET /apis/dashboard.grafana.app/v1/namespaces/{namespace}/dashboards/{name} ### Description Retrieves a specific dashboard by its namespace and name. ### Method GET ### Endpoint /apis/dashboard.grafana.app/v1/namespaces/{namespace}/dashboards/{name} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the dashboard. - **name** (string) - Required - The name of the dashboard. ### Response #### Success Response (200) - **kind** (string) - The resource kind, e.g., "Dashboard". - **apiVersion** (string) - The API version, e.g., "dashboard.grafana.app/v1". - **metadata** (object) - Contains metadata about the dashboard, including name, namespace, uid, resourceVersion, generation, creationTimestamp, annotations, and labels. - **spec** (object) - The desired state of the dashboard, specific to the resource type and API version. ``` -------------------------------- ### Install mcp-grafana with uvx Source: https://grafana.com/docs/grafana-cloud/machine-learning/mcp/set-up/client-configuration-examples Use this command if you have uv installed. uvx will automatically download and run the server. ```bash uvx mcp-grafana ``` -------------------------------- ### Started Load Test Example Source: https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-rest-api/load-tests This JSON object represents a load test that has been successfully created and started. ```json { "cost": null, "created": "2024-06-01T19:00:00Z", "distribution": null, "ended": null, "id": 1234, "k6_dependencies": { "k6": ">=v0.52", "k6/x/faker": ">=0.4.0" }, "k6_versions": { "k6": "v0.56.0", "k6/x/faker": "v0.4.1" }, "note": "", "options": null, "project_id": 12, "result": null, "result_details": null, "retention_expiry": "2024-06-07T19:00:00Z", "started_by": "user@example.com", "status": "created", "status_details": { "entered": "2024-06-01T19:00:00Z", "type": "created" }, "status_history": [ { "entered": "2024-06-01T19:00:00Z", "type": "created" } ], "test_id": 123 } ``` -------------------------------- ### Install the AI Observability Go SDK Source: https://grafana.com/docs/grafana-cloud/machine-learning/ai-observability/get-started/go Use this command to add the Sigil Go SDK to your project dependencies. ```bash go get github.com/grafana/sigil-sdk/go ``` -------------------------------- ### Get installed plugin info Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api Retrieves information about a specific plugin installed on a Grafana Cloud instance. ```APIDOC ## GET /api/instances//plugins/ ### Description Retrieves information about a specific plugin installed on a Grafana Cloud instance. ### Method GET ### Endpoint https://grafana.com/api/instances//plugins/ ### Response #### Success Response (200) - **id** (integer) - Unique identifier for the plugin installation. - **instanceId** (integer) - The ID of the Grafana Cloud instance. - **instanceUrl** (string) - The URL of the Grafana Cloud instance. - **instanceSlug** (string) - The slug of the Grafana Cloud instance. - **pluginId** (integer) - The internal ID of the plugin. - **pluginSlug** (string) - The slug of the plugin. - **pluginName** (string) - The name of the plugin. - **version** (string) - The installed version of the plugin. - **latestVersion** (string) - The latest available version of the plugin. - **createdAt** (string) - Timestamp when the plugin was installed. - **updatedAt** (string) - Timestamp when the plugin was last updated (null if never updated). - **links** (array) - Links related to the plugin installation. ### Response Example ```json { "id": 256519, "instanceId": 507363, "instanceUrl": "https://createcloudstack.grafana.net", "instanceSlug": "createcloudstack", "pluginId": 663, "pluginSlug": "grafana-github-datasource", "pluginName": "GitHub", "version": "1.3.1", "latestVersion": "1.3.1", "createdAt": "2023-01-04T08:50:42.000Z", "updatedAt": null, "links": [ { "rel": "self", "href": "/instances/createcloudstack/plugins/grafana-github-datasource" }, { "rel": "instance", "href": "/instances/createcloudstack" } ] } ``` ``` -------------------------------- ### GET /api/teams/:teamId/groups Response Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/team_sync Example response for a successful GET request to retrieve external groups for a team. ```json [ { "orgId": 1, "teamId": 1, "groupId": "cn=editors,ou=groups,dc=grafana,dc=org" } ] ``` -------------------------------- ### k6 Configuration File Example Source: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication Example JSON structure for a k6 configuration file to store cloud authentication details. ```json { "collectors": { "cloud": { "stackID": 12345, "stackURL": "https://stack-slug.grafana.net", "defaultProjectID": 123, "token": "YOUR_API_AUTH_TOKEN" } } } ``` -------------------------------- ### Example Template Query Source: https://grafana.com/docs/grafana-cloud/visualizations/dashboards/variables This is an example of a template query used in Grafana panels. Queries with text that starts with '$' are considered templates. ```text groupByNode(movingAverage(apps.$app.$server.counters.requests.count, 10), 2, 'sum') ``` -------------------------------- ### Example Systemd Service Status Output Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/set-up/install/ansible This is an example of the expected output when the `alloy.service` is active and running, indicating a successful installation and startup. ```shell alloy.service - Grafana Alloy Loaded: loaded (/etc/systemd/system/alloy.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-07-20 09:56:15 UTC; 36s ago Main PID: 3176 (alloy-linux-amd) Tasks: 8 (limit: 515) Memory: 92.5M CPU: 380ms CGroup: /system.slice/alloy.service └─3176 /usr/local/bin/alloy-linux-amd64 --config.file=/etc/grafana-cloud/alloy-config.yaml ``` -------------------------------- ### GET Current User Preferences Response Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/preferences Example response body for the GET /api/user/preferences endpoint, showing available preference fields. ```json HTTP/1.1 200 Content-Type: application/json { "theme": "", "homeDashboardId": 217, "homeDashboardUID": "jcIIG-07z", "timezone": "utc", "weekStart": "", "navbar": { "bookmarkUrls": null }, "queryHistory": { "homeTab": "" } } ``` -------------------------------- ### Example: Local File Component Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/get-started/components/configure-components Illustrates creating a `local.file` component with a specific label and filename argument. ```alloy local.file "config" { filename = "/etc/app/settings.yaml" } ``` -------------------------------- ### GET Current Org Preferences Response Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/preferences Example response body for the GET /api/org/preferences endpoint, showing available organization preference fields. ```json HTTP/1.1 200 Content-Type: application/json { "theme": "", "homeDashboardId": 0, "homeDashboardUID": "", "timezone": "", "weekStart": "", "navbar": { "bookmarkUrls": null }, "queryHistory": { "homeTab": "" } } ``` -------------------------------- ### Example Mute Timings Response Source: https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/set-up/provision-alerting-resources/http-api-provisioning An example JSON response for a GET mute timings request, showing a mute timing named 'weekends'. ```json HTTP/1.1 200 OK Content-Type: application/json [ { "name": "weekends", "time_intervals": [ { "weekdays": [ "saturday", "sunday" ] } ], "version": "", "provenance": "file" } ] ``` -------------------------------- ### Start Grafana Alloy Binary Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/set-up/run/binary Run the Alloy binary with a specified configuration file. Ensure you replace placeholders with actual paths. ```shell run ``` -------------------------------- ### Example output of SHOW GRANTS FOR 'db-o11y'@'%' Source: https://grafana.com/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql This is an example of the expected output when verifying user privileges for the 'db-o11y'@'%' user. ```none +------------------------------------------------------------------------------+ | Grants for db-o11y@% | +------------------------------------------------------------------------------+ | GRANT PROCESS, REPLICATION CLIENT ON *.* TO `db-o11y`@`%` | | GRANT SELECT, SHOW VIEW ON *.* TO `db-o11y`@`%` | | GRANT SELECT ON `performance_schema`.* TO `db-o11y`@`%` | | GRANT INSERT, UPDATE ON `performance_schema`.`setup_actors` TO `db-o11y`@`%` | +------------------------------------------------------------------------------+ ``` -------------------------------- ### Example: Schedule to run only once Source: https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-rest-api/schedules This example shows how to configure a schedule to run only once. By setting `recurrence_rule` to `null`, the test will execute solely at the specified `starts` datetime. ```json { "recurrence_rule": null, "starts": "2028-08-01T12:00:00.000Z" } ``` -------------------------------- ### Run Prometheus with Configuration Source: https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/noagent_linuxnode Starts the Prometheus server using the specified configuration file. Ensure `prometheus.yml` is in the same directory or provide the correct path. ```bash ./prometheus --config.file=./prometheus.yml ``` -------------------------------- ### Example Response for Get Single User by ID Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/user This is an example of a successful response when retrieving a single user by their ID, showing all user profile details. ```json HTTP/1.1 200 Content-Type: application/json { "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": "" } ``` -------------------------------- ### Sample file logging configuration Source: https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-asterisk Configure Asterisk to log messages to a file. This is necessary for collecting logs with the integration. ```none [logfiles] full = notice,warning,error,verbose,dtmf,fax ``` -------------------------------- ### Example Response for Get All Contact Points Source: https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/set-up/provision-alerting-resources/http-api-provisioning This is an example of a successful response when retrieving all contact points. It returns a JSON array of contact point objects. ```http HTTP/1.1 200 OK Content-Type: application/json [ { "uid": "", "name": "email receiver", "type": "email", "settings": { "addresses": "" }, "disableResolveMessage": false } ] ``` -------------------------------- ### Install walk_metrics.py Script Source: https://grafana.com/docs/grafana-cloud/cost-management-and-billing/analyze-costs/metrics-costs/graphite-metrics-costs Steps to download and make the `walk_metrics.py` script executable. This script helps in recursively finding metrics. ```none mkdir walk_metrics cd walk_metrics wget https://raw.githubusercontent.com/grafana/cloud-graphite-scripts/master/query/walk_metrics.py chmod +x walk_metrics.py ``` -------------------------------- ### Schedule Webhook Payload Example Source: https://grafana.com/docs/grafana-cloud/alerting-and-irm/irm/configure/integrations/webhooks/outgoing-webhooks This is an example JSON payload for a 'Shift Started' event. It contains details about the event, the schedule, the user involved, and the webhook configuration. ```json { "event": { "type": "shift started", "time": "2026-03-20T09:00:00+00:00" }, "schedule": { "id": "SCHED123ABC", "name": "Primary On-Call", "team": { "id": "TEAM456DEF", "name": "Platform Engineering" } }, "user": { "user_id": "USER789GHI", "username": "alice", "email": "alice@example.com" }, "webhook": { "id": "WH9NSKXWPXSNY3", "name": "Schedule Sync" } } ``` -------------------------------- ### Install Provider Helpers for LLM Clients Source: https://grafana.com/docs/grafana-cloud/machine-learning/ai-observability/get-started/go Install provider-specific SDKs to automatically capture generations from popular LLM clients like OpenAI, Anthropic, and Gemini. ```bash go get github.com/grafana/sigil-sdk/go-providers/openai go get github.com/grafana/sigil-sdk/go-providers/anthropic go get github.com/grafana/sigil-sdk/go-providers/gemini ``` -------------------------------- ### Create a Log File Source: https://grafana.com/docs/grafana-cloud/send-data/alloy/tutorials/logs-and-relabeling-basics Creates a directory and a sample log file for testing log collection. ```bash mkdir -p /tmp/alloy-logs echo "This is a log line" > /tmp/alloy-logs/log.log ``` -------------------------------- ### Get Data Source ID by Name (Request) Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/data_source Example HTTP request to get the ID of a data source using its name. Note: This API is deprecated. ```http GET /api/datasources/id/test_datasource HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk ``` -------------------------------- ### Install Grizzly CLI Source: https://grafana.com/docs/grafana-cloud/account-management/migration-guide/manually-migrate-to-grafana-cloud Download and make the Grizzly binary executable. Adapt the OS and architecture as needed. ```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 ``` -------------------------------- ### Sample res_prometheus configuration Source: https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-asterisk Configure the Prometheus exporter in Asterisk to expose metrics. Ensure it is enabled and set to the correct URI. ```none [general] enabled = yes core_metrics_enabled = yes uri = metrics ``` -------------------------------- ### Example Response for Getting Specific SSO Settings Source: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/http-api/api-legacy/sso-settings This is an example of the JSON response when retrieving SSO settings for a single provider, such as GitHub. It includes the ETag for caching. ```json HTTP/1.1 200 Content-Type: application/json ETag: db87f729761898ee { "id": "1", "provider": "github", "settings": { "apiUrl": "https://api.github.com/user", "clientId": "my_github_client", "clientSecret": "*********", "enabled": true, "scopes": "user:email,read:org" // rest of the settings }, "source": "system", } ``` -------------------------------- ### Example Project Response Source: https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-rest-api/deprecated-rest-api/projects This is an example of a successful HTTP response when retrieving project details. It includes the 'id', 'name', and 'description' of the project. ```http HTTP/1.1 200 Content-Type: application/json { "description": "Default project", "id": 5175, "name": "My first project", } ```