The required arguments for this resource vary depending on the type of data source selected (via the 'type' argument).
Use this resource for configuring multiple datasources, when that configuration (json_data_encoded
field) requires circular references like in the example below.
When using the
grafana_data_source_config
resource, the correspondinggrafana_data_source
resources must have thejson_data_encoded
andhttp_headers
fields ignored. Otherwise, an infinite update loop will occur. See the example below.
resource "grafana_data_source" "loki" {
type = "loki"
name = "loki"
url = "http://localhost:3100"
lifecycle {
ignore_changes = [json_data_encoded, http_headers]
}
}
resource "grafana_data_source" "tempo" {
type = "tempo"
name = "tempo"
url = "http://localhost:3200"
lifecycle {
ignore_changes = [json_data_encoded, http_headers]
}
}
resource "grafana_data_source_config" "loki" {
uid = grafana_data_source.loki.uid
json_data_encoded = jsonencode({
derivedFields = [
{
datasourceUid = grafana_data_source.tempo.uid
matcherRegex = "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)"
matcherType = "regex"
name = "traceID"
url = "$${__value.raw}"
}
]
})
}
resource "grafana_data_source_config" "tempo" {
uid = grafana_data_source.tempo.uid
json_data_encoded = jsonencode({
tracesToLogsV2 = {
customQuery = true
datasourceUid = grafana_data_source.loki.uid
filterBySpanID = false
filterByTraceID = false
query = "|=\"$${__trace.traceId}\" | json"
}
})
}
http_headers
(Map of String, Sensitive) Custom HTTP headersjson_data_encoded
(String) Serialized JSON string containing the json data. This attribute can be used to pass configuration options to the data source. To figure out what options a datasource has available, see its docs or inspect the network data when saving it from the Grafana UI. Note that keys in this map are usually camelCased.org_id
(String) The Organization ID. If not set, the Org ID defined in the provider block will be used.secure_json_data_encoded
(String, Sensitive) Serialized JSON string containing the secure json data. This attribute can be used to pass secure configuration options to the data source. To figure out what options a datasource has available, see its docs or inspect the network data when saving it from the Grafana UI. Note that keys in this map are usually camelCased.uid
(String) Unique identifier. If unset, this will be automatically generated.id
(String) The ID of this resource.Import is supported using the following syntax:
terraform import grafana_data_source_config.name "{{ uid }}"
terraform import grafana_data_source_config.name "{{ orgID }}:{{ uid }}"