datasource
Configure Grafana datasources for Prometheus and Loki. This guide provides a YAML configuration to set up Prometheus and Loki as data sources for Grafana, ensuring seamless data visualization.
Grafana Datasource Configuration for Loki
This document outlines the configuration for setting up Loki and Prometheus as datasources within Grafana. Proper datasource configuration is crucial for effective monitoring and logging, enabling you to visualize and analyze your system's behavior.
Prometheus Datasource Setup
The following YAML snippet configures the Prometheus datasource. Prometheus is commonly used for collecting and storing time-series metrics, which can be visualized alongside Loki logs in Grafana.
apiVersion: 1
deleteDatasources:
- name: prometheus
datasources:
- name: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
Loki Datasource Setup
This section details the configuration for the Loki datasource. Loki is a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus. Integrating it with Grafana allows for unified log querying and analysis.
datasources:
- name: loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: false
version: 1
editable: true
Complete Grafana Datasource Configuration
Combining both Prometheus and Loki configurations provides a comprehensive setup for observability within Grafana. This allows you to correlate metrics with logs, offering deeper insights into your applications and infrastructure.
apiVersion: 1
deleteDatasources:
- name: prometheus
- name: loki
datasources:
- name: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
- name: loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: false
version: 1
editable: true
Key Configuration Parameters
- name: The display name for the datasource in Grafana.
- type: The type of datasource (e.g., 'prometheus', 'loki').
- url: The HTTP endpoint for the datasource service.
- access: Specifies how Grafana accesses the datasource ('proxy' is common for internal services).
- isDefault: If set to true, this datasource will be selected by default when creating new dashboards.
- editable: Allows the datasource to be edited within the Grafana UI.