

grafana.getDataSource
Get details about a Grafana Datasource querying by either name, uid or ID
Example Usage
using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Grafana = Lbrlabs.PulumiPackage.Grafana;
using Grafana = Pulumi.Grafana;
return await Deployment.RunAsync(() =>
{
var prometheus = new Grafana.DataSource("prometheus", new()
{
Type = "prometheus",
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.GetDataSource.Invoke(new()
{
Name = prometheus.Name,
});
var fromId = Grafana.GetDataSource.Invoke(new()
{
Id = prometheus.Id,
});
var fromUid = Grafana.GetDataSource.Invoke(new()
{
Uid = prometheus.Uid,
});
});
package main
import (
"encoding/json"
"github.com/lbrlabs/pulumi-grafana/sdk/go/grafana"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
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 := grafana.NewDataSource(ctx, "prometheus", &grafana.DataSourceArgs{
Type: pulumi.String("prometheus"),
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
}
_ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
Name: prometheus.Name,
}, nil)
_ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
Id: prometheus.ID(),
}, nil)
_ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
Uid: prometheus.Uid,
}, nil)
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.DataSource;
import com.pulumi.grafana.DataSourceArgs;
import com.pulumi.grafana.GrafanaFunctions;
import com.pulumi.grafana.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")
.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 = GrafanaFunctions.getDataSource(GetDataSourceArgs.builder()
.name(prometheus.name())
.build());
final var fromId = GrafanaFunctions.getDataSource(GetDataSourceArgs.builder()
.id(prometheus.id())
.build());
final var fromUid = GrafanaFunctions.getDataSource(GetDataSourceArgs.builder()
.uid(prometheus.uid())
.build());
}
}
import pulumi
import json
import lbrlabs_pulumi_grafana as grafana
import pulumi_grafana as grafana
prometheus = grafana.DataSource("prometheus",
type="prometheus",
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.get_data_source_output(name=prometheus.name)
from_id = grafana.get_data_source_output(id=prometheus.id)
from_uid = grafana.get_data_source_output(uid=prometheus.uid)
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@lbrlabs/pulumi-grafana";
import * as grafana from "@pulumi/grafana";
const prometheus = new grafana.DataSource("prometheus", {
type: "prometheus",
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.getDataSourceOutput({
name: prometheus.name,
});
const fromId = grafana.getDataSourceOutput({
id: prometheus.id,
});
const fromUid = grafana.getDataSourceOutput({
uid: prometheus.uid,
});
resources:
prometheus:
type: grafana:DataSource
properties:
type: prometheus
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:getDataSource
Arguments:
name: ${prometheus.name}
fromId:
fn::invoke:
Function: grafana:getDataSource
Arguments:
id: ${prometheus.id}
fromUid:
fn::invoke:
Function: grafana: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(id: Optional[str] = None,
name: Optional[str] = None,
uid: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetDataSourceResult
def get_data_source_output(id: Optional[pulumi.Input[str]] = None,
name: 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:
getDataSource Result
The following output properties are available:
- Access
Mode string The method by which Grafana will access the data source:
proxy
ordirect
.- Basic
Auth boolEnabled Whether to enable basic auth for the data source.
- Basic
Auth stringUsername Basic auth username.
- Database
Name string (Required by some data source types) The name of the database to use on the selected data source server.
- Id string
The ID of this resource.
- Is
Default bool Whether to set the data source as default. This should only be
true
to a single data source.- Json
Data 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.
- 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.
- Access
Mode string The method by which Grafana will access the data source:
proxy
ordirect
.- Basic
Auth boolEnabled Whether to enable basic auth for the data source.
- Basic
Auth stringUsername Basic auth username.
- Database
Name string (Required by some data source types) The name of the database to use on the selected data source server.
- Id string
The ID of this resource.
- Is
Default bool Whether to set the data source as default. This should only be
true
to a single data source.- Json
Data 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.
- 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.
- access
Mode String The method by which Grafana will access the data source:
proxy
ordirect
.- basic
Auth BooleanEnabled Whether to enable basic auth for the data source.
- basic
Auth StringUsername Basic auth username.
- database
Name String (Required by some data source types) The name of the database to use on the selected data source server.
- id String
The ID of this resource.
- is
Default Boolean Whether to set the data source as default. This should only be
true
to a single data source.- json
Data 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.
- 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.
- access
Mode string The method by which Grafana will access the data source:
proxy
ordirect
.- basic
Auth booleanEnabled Whether to enable basic auth for the data source.
- basic
Auth stringUsername Basic auth username.
- database
Name string (Required by some data source types) The name of the database to use on the selected data source server.
- id string
The ID of this resource.
- is
Default boolean Whether to set the data source as default. This should only be
true
to a single data source.- json
Data 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.
- 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.
- access_
mode str The method by which Grafana will access the data source:
proxy
ordirect
.- basic_
auth_ boolenabled Whether to enable basic auth for the data source.
- basic_
auth_ strusername 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 ID of this resource.
- is_
default bool Whether to set the data source as default. This should only be
true
to a single data source.- 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.
- 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.
- access
Mode String The method by which Grafana will access the data source:
proxy
ordirect
.- basic
Auth BooleanEnabled Whether to enable basic auth for the data source.
- basic
Auth StringUsername Basic auth username.
- database
Name String (Required by some data source types) The name of the database to use on the selected data source server.
- id String
The ID of this resource.
- is
Default Boolean Whether to set the data source as default. This should only be
true
to a single data source.- json
Data 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.
- 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.
Package Details
- Repository
- grafana lbrlabs/pulumi-grafana
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
grafana
Terraform Provider.