Viewing docs for Grafana v2.21.0
published on Tuesday, Mar 3, 2026 by pulumiverse
published on Tuesday, Mar 3, 2026 by pulumiverse
Viewing docs for Grafana v2.21.0
published on Tuesday, Mar 3, 2026 by pulumiverse
published on Tuesday, Mar 3, 2026 by pulumiverse
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 "@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/v2/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)
public static Output<GetDataSourceResult> getDataSource(GetDataSourceArgs args, InvokeOptions options)
fn::invoke:
function: grafana:oss/getDataSource:getDataSource
arguments:
# arguments dictionaryThe 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:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- Is
Default bool - Whether to set the data source as default. This should only be
trueto 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
- Private
Data stringSource Connect Network Id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- Access
Mode string - The method by which Grafana will access the data source:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- Is
Default bool - Whether to set the data source as default. This should only be
trueto 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
- Private
Data stringSource Connect Network Id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- Org
Id string - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- access
Mode String - The method by which Grafana will access the data source:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- is
Default Boolean - Whether to set the data source as default. This should only be
trueto 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
- private
Data StringSource Connect Network Id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- org
Id String - The Organization ID. If not set, the Org ID defined in the provider block will be used.
- access
Mode string - The method by which Grafana will access the data source:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- is
Default boolean - Whether to set the data source as default. This should only be
trueto 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
- private
Data stringSource Connect Network Id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- org
Id 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:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- is_
default bool - Whether to set the data source as default. This should only be
trueto 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
- private_
data_ strsource_ connect_ network_ id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- access
Mode String - The method by which Grafana will access the data source:
proxyordirect. - 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 provider-assigned unique ID for this managed resource.
- is
Default Boolean - Whether to set the data source as default. This should only be
trueto 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
- private
Data StringSource Connect Network Id - (Can only be used with data sources in Grafana Cloud) The ID of the Private Data source Connect network to use with this data source.
- 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.
- org
Id 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
grafanaTerraform Provider.
Viewing docs for Grafana v2.21.0
published on Tuesday, Mar 3, 2026 by pulumiverse
published on Tuesday, Mar 3, 2026 by pulumiverse
