1. Packages
  2. Grafana Cloud
  3. API Docs
  4. enterprise
  5. DataSourceCacheConfig
Viewing docs for Grafana v2.23.0
published on Wednesday, Apr 1, 2026 by pulumiverse
grafana logo
Viewing docs for Grafana v2.23.0
published on Wednesday, Apr 1, 2026 by pulumiverse

    Manages cache configuration for a data source (Grafana Enterprise).

    Use this resource to enable or disable caching for a particular data source. You can also tune the TTL settings for the cache behaviour, or choose to use defaults.

    Deleting this resource will cause the cache to be disabled for the target data source.

    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 lokiCache = new grafana.enterprise.DataSourceCacheConfig("loki_cache", {
        datasourceUid: loki.uid,
        enabled: true,
        useDefaultTtl: false,
        ttlQueriesMs: 60000,
        ttlResourcesMs: 300000,
    });
    
    import pulumi
    import pulumiverse_grafana as grafana
    
    loki = grafana.oss.DataSource("loki",
        type="loki",
        name="loki",
        url="http://localhost:3100")
    loki_cache = grafana.enterprise.DataSourceCacheConfig("loki_cache",
        datasource_uid=loki.uid,
        enabled=True,
        use_default_ttl=False,
        ttl_queries_ms=60000,
        ttl_resources_ms=300000)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/v2/go/grafana/enterprise"
    	"github.com/pulumiverse/pulumi-grafana/sdk/v2/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
    		}
    		_, err = enterprise.NewDataSourceCacheConfig(ctx, "loki_cache", &enterprise.DataSourceCacheConfigArgs{
    			DatasourceUid:  loki.Uid,
    			Enabled:        pulumi.Bool(true),
    			UseDefaultTtl:  pulumi.Bool(false),
    			TtlQueriesMs:   pulumi.Int(60000),
    			TtlResourcesMs: pulumi.Int(300000),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    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 lokiCache = new Grafana.Enterprise.DataSourceCacheConfig("loki_cache", new()
        {
            DatasourceUid = loki.Uid,
            Enabled = true,
            UseDefaultTtl = false,
            TtlQueriesMs = 60000,
            TtlResourcesMs = 300000,
        });
    
    });
    
    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.enterprise.DataSourceCacheConfig;
    import com.pulumi.grafana.enterprise.DataSourceCacheConfigArgs;
    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 lokiCache = new DataSourceCacheConfig("lokiCache", DataSourceCacheConfigArgs.builder()
                .datasourceUid(loki.uid())
                .enabled(true)
                .useDefaultTtl(false)
                .ttlQueriesMs(60000)
                .ttlResourcesMs(300000)
                .build());
    
        }
    }
    
    resources:
      loki:
        type: grafana:oss:DataSource
        properties:
          type: loki
          name: loki
          url: http://localhost:3100
      lokiCache:
        type: grafana:enterprise:DataSourceCacheConfig
        name: loki_cache
        properties:
          datasourceUid: ${loki.uid}
          enabled: true
          useDefaultTtl: false
          ttlQueriesMs: 60000
          ttlResourcesMs: 300000
    

    Create DataSourceCacheConfig Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new DataSourceCacheConfig(name: string, args: DataSourceCacheConfigArgs, opts?: CustomResourceOptions);
    @overload
    def DataSourceCacheConfig(resource_name: str,
                              args: DataSourceCacheConfigArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def DataSourceCacheConfig(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              datasource_uid: Optional[str] = None,
                              enabled: Optional[bool] = None,
                              org_id: Optional[str] = None,
                              ttl_queries_ms: Optional[int] = None,
                              ttl_resources_ms: Optional[int] = None,
                              use_default_ttl: Optional[bool] = None)
    func NewDataSourceCacheConfig(ctx *Context, name string, args DataSourceCacheConfigArgs, opts ...ResourceOption) (*DataSourceCacheConfig, error)
    public DataSourceCacheConfig(string name, DataSourceCacheConfigArgs args, CustomResourceOptions? opts = null)
    public DataSourceCacheConfig(String name, DataSourceCacheConfigArgs args)
    public DataSourceCacheConfig(String name, DataSourceCacheConfigArgs args, CustomResourceOptions options)
    
    type: grafana:enterprise:DataSourceCacheConfig
    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 DataSourceCacheConfigArgs
    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 DataSourceCacheConfigArgs
    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 DataSourceCacheConfigArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DataSourceCacheConfigArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DataSourceCacheConfigArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var dataSourceCacheConfigResource = new Grafana.Enterprise.DataSourceCacheConfig("dataSourceCacheConfigResource", new()
    {
        DatasourceUid = "string",
        Enabled = false,
        OrgId = "string",
        TtlQueriesMs = 0,
        TtlResourcesMs = 0,
        UseDefaultTtl = false,
    });
    
    example, err := enterprise.NewDataSourceCacheConfig(ctx, "dataSourceCacheConfigResource", &enterprise.DataSourceCacheConfigArgs{
    	DatasourceUid:  pulumi.String("string"),
    	Enabled:        pulumi.Bool(false),
    	OrgId:          pulumi.String("string"),
    	TtlQueriesMs:   pulumi.Int(0),
    	TtlResourcesMs: pulumi.Int(0),
    	UseDefaultTtl:  pulumi.Bool(false),
    })
    
    var dataSourceCacheConfigResource = new DataSourceCacheConfig("dataSourceCacheConfigResource", DataSourceCacheConfigArgs.builder()
        .datasourceUid("string")
        .enabled(false)
        .orgId("string")
        .ttlQueriesMs(0)
        .ttlResourcesMs(0)
        .useDefaultTtl(false)
        .build());
    
    data_source_cache_config_resource = grafana.enterprise.DataSourceCacheConfig("dataSourceCacheConfigResource",
        datasource_uid="string",
        enabled=False,
        org_id="string",
        ttl_queries_ms=0,
        ttl_resources_ms=0,
        use_default_ttl=False)
    
    const dataSourceCacheConfigResource = new grafana.enterprise.DataSourceCacheConfig("dataSourceCacheConfigResource", {
        datasourceUid: "string",
        enabled: false,
        orgId: "string",
        ttlQueriesMs: 0,
        ttlResourcesMs: 0,
        useDefaultTtl: false,
    });
    
    type: grafana:enterprise:DataSourceCacheConfig
    properties:
        datasourceUid: string
        enabled: false
        orgId: string
        ttlQueriesMs: 0
        ttlResourcesMs: 0
        useDefaultTtl: false
    

    DataSourceCacheConfig 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 DataSourceCacheConfig resource accepts the following input properties:

    DatasourceUid string
    UID of the data source to configure.
    Enabled bool
    Whether caching is enabled for this data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    TtlQueriesMs int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    TtlResourcesMs int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    UseDefaultTtl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    DatasourceUid string
    UID of the data source to configure.
    Enabled bool
    Whether caching is enabled for this data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    TtlQueriesMs int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    TtlResourcesMs int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    UseDefaultTtl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid String
    UID of the data source to configure.
    enabled Boolean
    Whether caching is enabled for this data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs Integer
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs Integer
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl Boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid string
    UID of the data source to configure.
    enabled boolean
    Whether caching is enabled for this data source.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs number
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs number
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasource_uid str
    UID of the data source to configure.
    enabled bool
    Whether caching is enabled for this data source.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttl_queries_ms int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttl_resources_ms int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    use_default_ttl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid String
    UID of the data source to configure.
    enabled Boolean
    Whether caching is enabled for this data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs Number
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs Number
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl Boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DataSourceCacheConfig 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 DataSourceCacheConfig Resource

    Get an existing DataSourceCacheConfig 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?: DataSourceCacheConfigState, opts?: CustomResourceOptions): DataSourceCacheConfig
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datasource_uid: Optional[str] = None,
            enabled: Optional[bool] = None,
            org_id: Optional[str] = None,
            ttl_queries_ms: Optional[int] = None,
            ttl_resources_ms: Optional[int] = None,
            use_default_ttl: Optional[bool] = None) -> DataSourceCacheConfig
    func GetDataSourceCacheConfig(ctx *Context, name string, id IDInput, state *DataSourceCacheConfigState, opts ...ResourceOption) (*DataSourceCacheConfig, error)
    public static DataSourceCacheConfig Get(string name, Input<string> id, DataSourceCacheConfigState? state, CustomResourceOptions? opts = null)
    public static DataSourceCacheConfig get(String name, Output<String> id, DataSourceCacheConfigState state, CustomResourceOptions options)
    resources:  _:    type: grafana:enterprise:DataSourceCacheConfig    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.
    The following state arguments are supported:
    DatasourceUid string
    UID of the data source to configure.
    Enabled bool
    Whether caching is enabled for this data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    TtlQueriesMs int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    TtlResourcesMs int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    UseDefaultTtl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    DatasourceUid string
    UID of the data source to configure.
    Enabled bool
    Whether caching is enabled for this data source.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    TtlQueriesMs int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    TtlResourcesMs int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    UseDefaultTtl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid String
    UID of the data source to configure.
    enabled Boolean
    Whether caching is enabled for this data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs Integer
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs Integer
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl Boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid string
    UID of the data source to configure.
    enabled boolean
    Whether caching is enabled for this data source.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs number
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs number
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasource_uid str
    UID of the data source to configure.
    enabled bool
    Whether caching is enabled for this data source.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttl_queries_ms int
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttl_resources_ms int
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    use_default_ttl bool
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.
    datasourceUid String
    UID of the data source to configure.
    enabled Boolean
    Whether caching is enabled for this data source.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    ttlQueriesMs Number
    TTL for query caching, in milliseconds. Ignored if usedefaultttl is true.
    ttlResourcesMs Number
    TTL for resource caching, in milliseconds. Ignored if usedefaultttl is true.
    useDefaultTtl Boolean
    If true, use Grafana's default TTLs instead of custom values. Defaults to true.

    Import

    terraform import grafana_data_source_cache_config.name "{{ datasource_uid }}"
    terraform import grafana_data_source_cache_config.name "{{ orgID }}:{{ datasource_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 grafana Terraform Provider.
    grafana logo
    Viewing docs for Grafana v2.23.0
    published on Wednesday, Apr 1, 2026 by pulumiverse
      Try Pulumi Cloud free. Your team will thank you.