grafana.DataSourceConfig
Explore with Pulumi AI
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.oss.DataSourceConfigresource, the correspondinggrafana.oss.DataSourceresources must have thejson_data_encodedandhttp_headersfields ignored. Otherwise, an infinite update loop will occur. See the example below.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const loki = new grafana.oss.DataSource("loki", {
    type: "loki",
    name: "loki",
    url: "http://localhost:3100",
});
const tempo = new grafana.oss.DataSource("tempo", {
    type: "tempo",
    name: "tempo",
    url: "http://localhost:3200",
});
const lokiDataSourceConfig = new grafana.oss.DataSourceConfig("loki", {
    uid: loki.uid,
    jsonDataEncoded: pulumi.jsonStringify({
        derivedFields: [{
            datasourceUid: tempo.uid,
            matcherRegex: "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)",
            matcherType: "regex",
            name: "traceID",
            url: "${__value.raw}",
        }],
    }),
});
const tempoDataSourceConfig = new grafana.oss.DataSourceConfig("tempo", {
    uid: tempo.uid,
    jsonDataEncoded: pulumi.jsonStringify({
        tracesToLogsV2: {
            customQuery: true,
            datasourceUid: loki.uid,
            filterBySpanID: false,
            filterByTraceID: false,
            query: "|=\"${__trace.traceId}\" | json",
        },
    }),
});
import pulumi
import json
import pulumiverse_grafana as grafana
loki = grafana.oss.DataSource("loki",
    type="loki",
    name="loki",
    url="http://localhost:3100")
tempo = grafana.oss.DataSource("tempo",
    type="tempo",
    name="tempo",
    url="http://localhost:3200")
loki_data_source_config = grafana.oss.DataSourceConfig("loki",
    uid=loki.uid,
    json_data_encoded=pulumi.Output.json_dumps({
        "derivedFields": [{
            "datasourceUid": tempo.uid,
            "matcherRegex": "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)",
            "matcherType": "regex",
            "name": "traceID",
            "url": "${__value.raw}",
        }],
    }))
tempo_data_source_config = grafana.oss.DataSourceConfig("tempo",
    uid=tempo.uid,
    json_data_encoded=pulumi.Output.json_dumps({
        "tracesToLogsV2": {
            "customQuery": True,
            "datasourceUid": loki.uid,
            "filterBySpanID": False,
            "filterByTraceID": False,
            "query": "|=\"${__trace.traceId}\" | json",
        },
    }))
package main
import (
	"encoding/json"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		loki, err := oss.NewDataSource(ctx, "loki", &oss.DataSourceArgs{
			Type: pulumi.String("loki"),
			Name: pulumi.String("loki"),
			Url:  pulumi.String("http://localhost:3100"),
		})
		if err != nil {
			return err
		}
		tempo, err := oss.NewDataSource(ctx, "tempo", &oss.DataSourceArgs{
			Type: pulumi.String("tempo"),
			Name: pulumi.String("tempo"),
			Url:  pulumi.String("http://localhost:3200"),
		})
		if err != nil {
			return err
		}
		_, err = oss.NewDataSourceConfig(ctx, "loki", &oss.DataSourceConfigArgs{
			Uid: loki.Uid,
			JsonDataEncoded: tempo.Uid.ApplyT(func(uid string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON0, err := json.Marshal(map[string]interface{}{
					"derivedFields": []map[string]interface{}{
						map[string]interface{}{
							"datasourceUid": uid,
							"matcherRegex":  "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)",
							"matcherType":   "regex",
							"name":          "traceID",
							"url":           "${__value.raw}",
						},
					},
				})
				if err != nil {
					return _zero, err
				}
				json0 := string(tmpJSON0)
				return pulumi.String(json0), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		_, err = oss.NewDataSourceConfig(ctx, "tempo", &oss.DataSourceConfigArgs{
			Uid: tempo.Uid,
			JsonDataEncoded: loki.Uid.ApplyT(func(uid string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON1, err := json.Marshal(map[string]interface{}{
					"tracesToLogsV2": map[string]interface{}{
						"customQuery":     true,
						"datasourceUid":   uid,
						"filterBySpanID":  false,
						"filterByTraceID": false,
						"query":           "|=\"${__trace.traceId}\" | json",
					},
				})
				if err != nil {
					return _zero, err
				}
				json1 := string(tmpJSON1)
				return pulumi.String(json1), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Grafana = Pulumiverse.Grafana;
return await Deployment.RunAsync(() => 
{
    var loki = new Grafana.Oss.DataSource("loki", new()
    {
        Type = "loki",
        Name = "loki",
        Url = "http://localhost:3100",
    });
    var tempo = new Grafana.Oss.DataSource("tempo", new()
    {
        Type = "tempo",
        Name = "tempo",
        Url = "http://localhost:3200",
    });
    var lokiDataSourceConfig = new Grafana.Oss.DataSourceConfig("loki", new()
    {
        Uid = loki.Uid,
        JsonDataEncoded = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
        {
            ["derivedFields"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["datasourceUid"] = tempo.Uid,
                    ["matcherRegex"] = "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)",
                    ["matcherType"] = "regex",
                    ["name"] = "traceID",
                    ["url"] = "${__value.raw}",
                },
            },
        })),
    });
    var tempoDataSourceConfig = new Grafana.Oss.DataSourceConfig("tempo", new()
    {
        Uid = tempo.Uid,
        JsonDataEncoded = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
        {
            ["tracesToLogsV2"] = new Dictionary<string, object?>
            {
                ["customQuery"] = true,
                ["datasourceUid"] = loki.Uid,
                ["filterBySpanID"] = false,
                ["filterByTraceID"] = false,
                ["query"] = "|=\"${__trace.traceId}\" | json",
            },
        })),
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.oss.DataSource;
import com.pulumi.grafana.oss.DataSourceArgs;
import com.pulumi.grafana.oss.DataSourceConfig;
import com.pulumi.grafana.oss.DataSourceConfigArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        var loki = new DataSource("loki", DataSourceArgs.builder()
            .type("loki")
            .name("loki")
            .url("http://localhost:3100")
            .build());
        var tempo = new DataSource("tempo", DataSourceArgs.builder()
            .type("tempo")
            .name("tempo")
            .url("http://localhost:3200")
            .build());
        var lokiDataSourceConfig = new DataSourceConfig("lokiDataSourceConfig", DataSourceConfigArgs.builder()
            .uid(loki.uid())
            .jsonDataEncoded(tempo.uid().applyValue(uid -> serializeJson(
                jsonObject(
                    jsonProperty("derivedFields", jsonArray(jsonObject(
                        jsonProperty("datasourceUid", uid),
                        jsonProperty("matcherRegex", "[tT]race_?[iI][dD]\"?[:=]\"?(\\w+)"),
                        jsonProperty("matcherType", "regex"),
                        jsonProperty("name", "traceID"),
                        jsonProperty("url", "${__value.raw}")
                    )))
                ))))
            .build());
        var tempoDataSourceConfig = new DataSourceConfig("tempoDataSourceConfig", DataSourceConfigArgs.builder()
            .uid(tempo.uid())
            .jsonDataEncoded(loki.uid().applyValue(uid -> serializeJson(
                jsonObject(
                    jsonProperty("tracesToLogsV2", jsonObject(
                        jsonProperty("customQuery", true),
                        jsonProperty("datasourceUid", uid),
                        jsonProperty("filterBySpanID", false),
                        jsonProperty("filterByTraceID", false),
                        jsonProperty("query", "|=\"${__trace.traceId}\" | json")
                    ))
                ))))
            .build());
    }
}
resources:
  loki:
    type: grafana:oss:DataSource
    properties:
      type: loki
      name: loki
      url: http://localhost:3100
  tempo:
    type: grafana:oss:DataSource
    properties:
      type: tempo
      name: tempo
      url: http://localhost:3200
  lokiDataSourceConfig:
    type: grafana:oss:DataSourceConfig
    name: loki
    properties:
      uid: ${loki.uid}
      jsonDataEncoded:
        fn::toJSON:
          derivedFields:
            - datasourceUid: ${tempo.uid}
              matcherRegex: '[tT]race_?[iI][dD]"?[:=]"?(\w+)'
              matcherType: regex
              name: traceID
              url: $${__value.raw}
  tempoDataSourceConfig:
    type: grafana:oss:DataSourceConfig
    name: tempo
    properties:
      uid: ${tempo.uid}
      jsonDataEncoded:
        fn::toJSON:
          tracesToLogsV2:
            customQuery: true
            datasourceUid: ${loki.uid}
            filterBySpanID: false
            filterByTraceID: false
            query: '|="$${__trace.traceId}" | json'
Create DataSourceConfig Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DataSourceConfig(name: string, args?: DataSourceConfigArgs, opts?: CustomResourceOptions);@overload
def DataSourceConfig(resource_name: str,
                     args: Optional[DataSourceConfigArgs] = None,
                     opts: Optional[ResourceOptions] = None)
@overload
def DataSourceConfig(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     http_headers: Optional[Mapping[str, str]] = None,
                     json_data_encoded: Optional[str] = None,
                     org_id: Optional[str] = None,
                     secure_json_data_encoded: Optional[str] = None,
                     uid: Optional[str] = None)func NewDataSourceConfig(ctx *Context, name string, args *DataSourceConfigArgs, opts ...ResourceOption) (*DataSourceConfig, error)public DataSourceConfig(string name, DataSourceConfigArgs? args = null, CustomResourceOptions? opts = null)
public DataSourceConfig(String name, DataSourceConfigArgs args)
public DataSourceConfig(String name, DataSourceConfigArgs args, CustomResourceOptions options)
type: grafana:DataSourceConfig
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DataSourceConfigArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DataSourceConfigArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DataSourceConfigArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DataSourceConfigArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DataSourceConfigArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
DataSourceConfig Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The DataSourceConfig resource accepts the following input properties:
- HttpHeaders Dictionary<string, string>
- Custom HTTP headers
- JsonData stringEncoded 
- 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.
- OrgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- SecureJson stringData Encoded 
- 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.
- HttpHeaders map[string]string
- Custom HTTP headers
- JsonData stringEncoded 
- 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.
- OrgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- SecureJson stringData Encoded 
- 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.
- httpHeaders Map<String,String>
- Custom HTTP headers
- jsonData StringEncoded 
- 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.
- orgId String
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson StringData Encoded 
- 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.
- httpHeaders {[key: string]: string}
- Custom HTTP headers
- jsonData stringEncoded 
- 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.
- orgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson stringData Encoded 
- 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.
- http_headers Mapping[str, str]
- Custom HTTP headers
- json_data_ strencoded 
- 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 str
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secure_json_ strdata_ encoded 
- 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 str
- Unique identifier. If unset, this will be automatically generated.
- httpHeaders Map<String>
- Custom HTTP headers
- jsonData StringEncoded 
- 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.
- orgId String
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson StringData Encoded 
- 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the DataSourceConfig resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing DataSourceConfig Resource
Get an existing DataSourceConfig resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: DataSourceConfigState, opts?: CustomResourceOptions): DataSourceConfig@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        http_headers: Optional[Mapping[str, str]] = None,
        json_data_encoded: Optional[str] = None,
        org_id: Optional[str] = None,
        secure_json_data_encoded: Optional[str] = None,
        uid: Optional[str] = None) -> DataSourceConfigfunc GetDataSourceConfig(ctx *Context, name string, id IDInput, state *DataSourceConfigState, opts ...ResourceOption) (*DataSourceConfig, error)public static DataSourceConfig Get(string name, Input<string> id, DataSourceConfigState? state, CustomResourceOptions? opts = null)public static DataSourceConfig get(String name, Output<String> id, DataSourceConfigState state, CustomResourceOptions options)resources:  _:    type: grafana:DataSourceConfig    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- HttpHeaders Dictionary<string, string>
- Custom HTTP headers
- JsonData stringEncoded 
- 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.
- OrgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- SecureJson stringData Encoded 
- 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.
- HttpHeaders map[string]string
- Custom HTTP headers
- JsonData stringEncoded 
- 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.
- OrgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- SecureJson stringData Encoded 
- 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.
- httpHeaders Map<String,String>
- Custom HTTP headers
- jsonData StringEncoded 
- 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.
- orgId String
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson StringData Encoded 
- 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.
- httpHeaders {[key: string]: string}
- Custom HTTP headers
- jsonData stringEncoded 
- 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.
- orgId string
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson stringData Encoded 
- 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.
- http_headers Mapping[str, str]
- Custom HTTP headers
- json_data_ strencoded 
- 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 str
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secure_json_ strdata_ encoded 
- 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 str
- Unique identifier. If unset, this will be automatically generated.
- httpHeaders Map<String>
- Custom HTTP headers
- jsonData StringEncoded 
- 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.
- orgId String
- The Organization ID. If not set, the Org ID defined in the provider block will be used.
- secureJson StringData Encoded 
- 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.
Import
$ pulumi import grafana:index/dataSourceConfig:DataSourceConfig name "{{ uid }}"
$ pulumi import grafana:index/dataSourceConfig:DataSourceConfig name "{{ orgID }}:{{ uid }}"
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- grafana pulumiverse/pulumi-grafana
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the grafanaTerraform Provider.
