1. Packages
  2. Grafana Cloud
  3. API Docs
  4. getDataSource
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse

grafana.getDataSource

Explore with Pulumi AI

grafana logo
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse
    Deprecated: grafana.index/getdatasource.getDataSource has been deprecated in favor of grafana.oss/getdatasource.getDataSource

    Get details about a Grafana Datasource querying by either name, uid or ID

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumi/grafana";
    import * as grafana from "@pulumiverse/grafana";
    
    const prometheus = new grafana.oss.DataSource("prometheus", {
        type: "prometheus",
        name: "prometheus-ds-test",
        uid: "prometheus-ds-test-uid",
        url: "https://my-instance.com",
        basicAuthEnabled: true,
        basicAuthUsername: "username",
        jsonDataEncoded: JSON.stringify({
            httpMethod: "POST",
            prometheusType: "Mimir",
            prometheusVersion: "2.4.0",
        }),
        secureJsonDataEncoded: JSON.stringify({
            basicAuthPassword: "password",
        }),
    });
    const fromName = grafana.oss.getDataSourceOutput({
        name: prometheus.name,
    });
    const fromUid = grafana.oss.getDataSourceOutput({
        uid: prometheus.uid,
    });
    
    import pulumi
    import json
    import pulumi_grafana as grafana
    import pulumiverse_grafana as grafana
    
    prometheus = grafana.oss.DataSource("prometheus",
        type="prometheus",
        name="prometheus-ds-test",
        uid="prometheus-ds-test-uid",
        url="https://my-instance.com",
        basic_auth_enabled=True,
        basic_auth_username="username",
        json_data_encoded=json.dumps({
            "httpMethod": "POST",
            "prometheusType": "Mimir",
            "prometheusVersion": "2.4.0",
        }),
        secure_json_data_encoded=json.dumps({
            "basicAuthPassword": "password",
        }))
    from_name = grafana.oss.get_data_source_output(name=prometheus.name)
    from_uid = grafana.oss.get_data_source_output(uid=prometheus.uid)
    
    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 {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"httpMethod":        "POST",
    			"prometheusType":    "Mimir",
    			"prometheusVersion": "2.4.0",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"basicAuthPassword": "password",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		prometheus, err := oss.NewDataSource(ctx, "prometheus", &oss.DataSourceArgs{
    			Type:                  pulumi.String("prometheus"),
    			Name:                  pulumi.String("prometheus-ds-test"),
    			Uid:                   pulumi.String("prometheus-ds-test-uid"),
    			Url:                   pulumi.String("https://my-instance.com"),
    			BasicAuthEnabled:      pulumi.Bool(true),
    			BasicAuthUsername:     pulumi.String("username"),
    			JsonDataEncoded:       pulumi.String(json0),
    			SecureJsonDataEncoded: pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		_ = oss.LookupDataSourceOutput(ctx, oss.GetDataSourceOutputArgs{
    			Name: prometheus.Name,
    		}, nil)
    		_ = oss.LookupDataSourceOutput(ctx, oss.GetDataSourceOutputArgs{
    			Uid: prometheus.Uid,
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Grafana = Pulumi.Grafana;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var prometheus = new Grafana.Oss.DataSource("prometheus", new()
        {
            Type = "prometheus",
            Name = "prometheus-ds-test",
            Uid = "prometheus-ds-test-uid",
            Url = "https://my-instance.com",
            BasicAuthEnabled = true,
            BasicAuthUsername = "username",
            JsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["httpMethod"] = "POST",
                ["prometheusType"] = "Mimir",
                ["prometheusVersion"] = "2.4.0",
            }),
            SecureJsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["basicAuthPassword"] = "password",
            }),
        });
    
        var fromName = Grafana.Oss.GetDataSource.Invoke(new()
        {
            Name = prometheus.Name,
        });
    
        var fromUid = Grafana.Oss.GetDataSource.Invoke(new()
        {
            Uid = prometheus.Uid,
        });
    
    });
    
    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.OssFunctions;
    import com.pulumi.grafana.oss.inputs.GetDataSourceArgs;
    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 prometheus = new DataSource("prometheus", DataSourceArgs.builder()
                .type("prometheus")
                .name("prometheus-ds-test")
                .uid("prometheus-ds-test-uid")
                .url("https://my-instance.com")
                .basicAuthEnabled(true)
                .basicAuthUsername("username")
                .jsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("httpMethod", "POST"),
                        jsonProperty("prometheusType", "Mimir"),
                        jsonProperty("prometheusVersion", "2.4.0")
                    )))
                .secureJsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("basicAuthPassword", "password")
                    )))
                .build());
    
            final var fromName = OssFunctions.getDataSource(GetDataSourceArgs.builder()
                .name(prometheus.name())
                .build());
    
            final var fromUid = OssFunctions.getDataSource(GetDataSourceArgs.builder()
                .uid(prometheus.uid())
                .build());
    
        }
    }
    
    resources:
      prometheus:
        type: grafana:oss:DataSource
        properties:
          type: prometheus
          name: prometheus-ds-test
          uid: prometheus-ds-test-uid
          url: https://my-instance.com
          basicAuthEnabled: true
          basicAuthUsername: username
          jsonDataEncoded:
            fn::toJSON:
              httpMethod: POST
              prometheusType: Mimir
              prometheusVersion: 2.4.0
          secureJsonDataEncoded:
            fn::toJSON:
              basicAuthPassword: password
    variables:
      fromName:
        fn::invoke:
          Function: grafana:oss:getDataSource
          Arguments:
            name: ${prometheus.name}
      fromUid:
        fn::invoke:
          Function: grafana:oss:getDataSource
          Arguments:
            uid: ${prometheus.uid}
    

    Using getDataSource

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getDataSource(args: GetDataSourceArgs, opts?: InvokeOptions): Promise<GetDataSourceResult>
    function getDataSourceOutput(args: GetDataSourceOutputArgs, opts?: InvokeOptions): Output<GetDataSourceResult>
    def get_data_source(name: Optional[str] = None,
                        org_id: Optional[str] = None,
                        uid: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetDataSourceResult
    def get_data_source_output(name: Optional[pulumi.Input[str]] = None,
                        org_id: Optional[pulumi.Input[str]] = None,
                        uid: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetDataSourceResult]
    func LookupDataSource(ctx *Context, args *LookupDataSourceArgs, opts ...InvokeOption) (*LookupDataSourceResult, error)
    func LookupDataSourceOutput(ctx *Context, args *LookupDataSourceOutputArgs, opts ...InvokeOption) LookupDataSourceResultOutput

    > Note: This function is named LookupDataSource in the Go SDK.

    public static class GetDataSource 
    {
        public static Task<GetDataSourceResult> InvokeAsync(GetDataSourceArgs args, InvokeOptions? opts = null)
        public static Output<GetDataSourceResult> Invoke(GetDataSourceInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDataSourceResult> getDataSource(GetDataSourceArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: grafana:index/getDataSource:getDataSource
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    Name string
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    name String
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String
    name string
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid string
    name str
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid str
    name String
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String

    getDataSource Result

    The following output properties are available:

    AccessMode string
    The method by which Grafana will access the data source: proxy or direct.
    BasicAuthEnabled bool
    Whether to enable basic auth for the data source.
    BasicAuthUsername string
    Basic auth username.
    DatabaseName string
    (Required by some data source types) The name of the database to use on the selected data source server.
    Id string
    The provider-assigned unique ID for this managed resource.
    IsDefault bool
    Whether to set the data source as default. This should only be true to a single data source.
    JsonDataEncoded 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.
    Name string
    Type string
    The data source type. Must be one of the supported data source keywords.
    Uid string
    Url string
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    Username string
    (Required by some data source types) The username to use to authenticate to the data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    AccessMode string
    The method by which Grafana will access the data source: proxy or direct.
    BasicAuthEnabled bool
    Whether to enable basic auth for the data source.
    BasicAuthUsername string
    Basic auth username.
    DatabaseName string
    (Required by some data source types) The name of the database to use on the selected data source server.
    Id string
    The provider-assigned unique ID for this managed resource.
    IsDefault bool
    Whether to set the data source as default. This should only be true to a single data source.
    JsonDataEncoded 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.
    Name string
    Type string
    The data source type. Must be one of the supported data source keywords.
    Uid string
    Url string
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    Username string
    (Required by some data source types) The username to use to authenticate to the data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    accessMode String
    The method by which Grafana will access the data source: proxy or direct.
    basicAuthEnabled Boolean
    Whether to enable basic auth for the data source.
    basicAuthUsername String
    Basic auth username.
    databaseName String
    (Required by some data source types) The name of the database to use on the selected data source server.
    id String
    The provider-assigned unique ID for this managed resource.
    isDefault Boolean
    Whether to set the data source as default. This should only be true to a single data source.
    jsonDataEncoded 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.
    name String
    type String
    The data source type. Must be one of the supported data source keywords.
    uid String
    url String
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    username String
    (Required by some data source types) The username to use to authenticate to the data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    accessMode string
    The method by which Grafana will access the data source: proxy or direct.
    basicAuthEnabled boolean
    Whether to enable basic auth for the data source.
    basicAuthUsername string
    Basic auth username.
    databaseName string
    (Required by some data source types) The name of the database to use on the selected data source server.
    id string
    The provider-assigned unique ID for this managed resource.
    isDefault boolean
    Whether to set the data source as default. This should only be true to a single data source.
    jsonDataEncoded 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.
    name string
    type string
    The data source type. Must be one of the supported data source keywords.
    uid string
    url string
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    username string
    (Required by some data source types) The username to use to authenticate to the data source.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    access_mode str
    The method by which Grafana will access the data source: proxy or direct.
    basic_auth_enabled bool
    Whether to enable basic auth for the data source.
    basic_auth_username str
    Basic auth username.
    database_name str
    (Required by some data source types) The name of the database to use on the selected data source server.
    id str
    The provider-assigned unique ID for this managed resource.
    is_default bool
    Whether to set the data source as default. This should only be true to a single data source.
    json_data_encoded str
    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.
    name str
    type str
    The data source type. Must be one of the supported data source keywords.
    uid str
    url str
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    username str
    (Required by some data source types) The username to use to authenticate to the data source.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    accessMode String
    The method by which Grafana will access the data source: proxy or direct.
    basicAuthEnabled Boolean
    Whether to enable basic auth for the data source.
    basicAuthUsername String
    Basic auth username.
    databaseName String
    (Required by some data source types) The name of the database to use on the selected data source server.
    id String
    The provider-assigned unique ID for this managed resource.
    isDefault Boolean
    Whether to set the data source as default. This should only be true to a single data source.
    jsonDataEncoded 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.
    name String
    type String
    The data source type. Must be one of the supported data source keywords.
    uid String
    url String
    The URL for the data source. The type of URL required varies depending on the chosen data source type.
    username String
    (Required by some data source types) The username to use to authenticate to the data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.

    Package Details

    Repository
    grafana pulumiverse/pulumi-grafana
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the grafana Terraform Provider.
    grafana logo
    Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse