published on Friday, Aug 7, 2026 by pulumiverse
published on Friday, Aug 7, 2026 by pulumiverse
Manages Grafana Saved Queries, also known as the Query Library, using the Grafana App Platform API (queries.grafana.app/v1).
The datasource query stored in each target, the target’s variable replacements, and a variable’s value list definition are passed as raw JSON strings (use jsonencode()) because their shape depends on the datasource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const example = new grafana.apps.v1.Query("example", {
metadata: {
uid: "example-saved-query",
},
spec: {
title: "Requests per second",
description: "Prometheus rate of HTTP requests",
isVisible: true,
tags: [
"http",
"prometheus",
],
targets: [{
propertiesJson: JSON.stringify({
refId: "A",
expr: "rate(http_requests_total[$__rate_interval])",
datasource: {
type: "prometheus",
uid: "my-prometheus-uid",
},
}),
}],
},
});
import pulumi
import json
import pulumiverse_grafana as grafana
example = grafana.apps.v1.Query("example",
metadata={
"uid": "example-saved-query",
},
spec={
"title": "Requests per second",
"description": "Prometheus rate of HTTP requests",
"is_visible": True,
"tags": [
"http",
"prometheus",
],
"targets": [{
"properties_json": json.dumps({
"refId": "A",
"expr": "rate(http_requests_total[$__rate_interval])",
"datasource": {
"type": "prometheus",
"uid": "my-prometheus-uid",
},
}),
}],
})
package main
import (
"encoding/json"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-grafana/sdk/v2/go/grafana/apps"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
tmpJSON0, err := json.Marshal(map[string]interface{}{
"refId": "A",
"expr": "rate(http_requests_total[$__rate_interval])",
"datasource": map[string]interface{}{
"type": "prometheus",
"uid": "my-prometheus-uid",
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = apps.NewQuery(ctx, "example", &apps.QueryArgs{
Metadata: &v1.QueryMetadataArgs{
Uid: pulumi.String("example-saved-query"),
},
Spec: &v1.QuerySpecArgs{
Title: pulumi.String("Requests per second"),
Description: pulumi.String("Prometheus rate of HTTP requests"),
IsVisible: pulumi.Bool(true),
Tags: pulumi.StringArray{
pulumi.String("http"),
pulumi.String("prometheus"),
},
Targets: v1.QuerySpecTargetArray{
&v1.QuerySpecTargetArgs{
PropertiesJson: pulumi.String(pulumi.String(json0)),
},
},
},
})
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 example = new Grafana.Apps.V1.Query("example", new()
{
Metadata = new Grafana.Apps.V1.Inputs.QueryMetadataArgs
{
Uid = "example-saved-query",
},
Spec = new Grafana.Apps.V1.Inputs.QuerySpecArgs
{
Title = "Requests per second",
Description = "Prometheus rate of HTTP requests",
IsVisible = true,
Tags = new[]
{
"http",
"prometheus",
},
Targets = new[]
{
new Grafana.Apps.V1.Inputs.QuerySpecTargetArgs
{
PropertiesJson = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["refId"] = "A",
["expr"] = "rate(http_requests_total[$__rate_interval])",
["datasource"] = new Dictionary<string, object?>
{
["type"] = "prometheus",
["uid"] = "my-prometheus-uid",
},
}),
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.apps_v1.Query;
import com.pulumi.grafana.apps_v1.QueryArgs;
import com.pulumi.grafana.apps.inputs.QueryMetadataArgs;
import com.pulumi.grafana.apps.inputs.QuerySpecArgs;
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 example = new Query("example", QueryArgs.builder()
.metadata(QueryMetadataArgs.builder()
.uid("example-saved-query")
.build())
.spec(QuerySpecArgs.builder()
.title("Requests per second")
.description("Prometheus rate of HTTP requests")
.isVisible(true)
.tags(
"http",
"prometheus")
.targets(QuerySpecTargetArgs.builder()
.propertiesJson(serializeJson(
jsonObject(
jsonProperty("refId", "A"),
jsonProperty("expr", "rate(http_requests_total[$__rate_interval])"),
jsonProperty("datasource", jsonObject(
jsonProperty("type", "prometheus"),
jsonProperty("uid", "my-prometheus-uid")
))
)))
.build())
.build())
.build());
}
}
resources:
example:
type: grafana:apps/v1:Query
properties:
metadata:
uid: example-saved-query
spec:
title: Requests per second
description: Prometheus rate of HTTP requests
isVisible: true
tags:
- http
- prometheus
targets:
- propertiesJson:
fn::toJSON:
refId: A
expr: rate(http_requests_total[$__rate_interval])
datasource:
type: prometheus
uid: my-prometheus-uid
Example coming soon!
Create Query Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Query(name: string, args?: QueryArgs, opts?: CustomResourceOptions);@overload
def Query(resource_name: str,
args: Optional[QueryArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def Query(resource_name: str,
opts: Optional[ResourceOptions] = None,
metadata: Optional[QueryMetadataArgs] = None,
options: Optional[QueryOptionsArgs] = None,
spec: Optional[QuerySpecArgs] = None)func NewQuery(ctx *Context, name string, args *QueryArgs, opts ...ResourceOption) (*Query, error)public Query(string name, QueryArgs? args = null, CustomResourceOptions? opts = null)type: grafana:apps/v1/query:Query
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "grafana_apps_v1_query" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args QueryArgs
- 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 QueryArgs
- 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 QueryArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Query 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 Query resource accepts the following input properties:
- Metadata
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Metadata - The metadata of the resource.
- Options
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Options - Options for applying the resource.
- Spec
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Spec - The spec of the resource.
- Metadata
Query
Metadata Args - The metadata of the resource.
- Options
Query
Options Args - Options for applying the resource.
- Spec
Query
Spec Args - The spec of the resource.
- metadata
Query
Metadata - The metadata of the resource.
- options
Query
Options - Options for applying the resource.
- spec
Query
Spec - The spec of the resource.
- metadata
Query
Metadata - The metadata of the resource.
- options
Query
Options - Options for applying the resource.
- spec
Query
Spec - The spec of the resource.
- metadata
Query
Metadata Args - The metadata of the resource.
- options
Query
Options Args - Options for applying the resource.
- spec
Query
Spec Args - The spec of the resource.
- metadata Property Map
- The metadata of the resource.
- options Property Map
- Options for applying the resource.
- spec Property Map
- The spec of the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the Query 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 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 Query Resource
Get an existing Query 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?: QueryState, opts?: CustomResourceOptions): Query@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
metadata: Optional[QueryMetadataArgs] = None,
options: Optional[QueryOptionsArgs] = None,
spec: Optional[QuerySpecArgs] = None) -> Queryfunc GetQuery(ctx *Context, name string, id IDInput, state *QueryState, opts ...ResourceOption) (*Query, error)public static Query Get(string name, Input<string> id, QueryState? state, CustomResourceOptions? opts = null)public static Query get(String name, Output<String> id, QueryState state, CustomResourceOptions options)resources: _: type: grafana:apps/v1/query:Query get: id: ${id}import {
to = grafana_apps_v1_query.example
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.
- Metadata
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Metadata - The metadata of the resource.
- Options
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Options - Options for applying the resource.
- Spec
Pulumiverse.
Grafana. Apps. V1. Inputs. Query Spec - The spec of the resource.
- Metadata
Query
Metadata Args - The metadata of the resource.
- Options
Query
Options Args - Options for applying the resource.
- Spec
Query
Spec Args - The spec of the resource.
- metadata
Query
Metadata - The metadata of the resource.
- options
Query
Options - Options for applying the resource.
- spec
Query
Spec - The spec of the resource.
- metadata
Query
Metadata - The metadata of the resource.
- options
Query
Options - Options for applying the resource.
- spec
Query
Spec - The spec of the resource.
- metadata
Query
Metadata Args - The metadata of the resource.
- options
Query
Options Args - Options for applying the resource.
- spec
Query
Spec Args - The spec of the resource.
- metadata Property Map
- The metadata of the resource.
- options Property Map
- Options for applying the resource.
- spec Property Map
- The spec of the resource.
Supporting Types
QueryMetadata, QueryMetadataArgs
- Uid string
- The unique identifier of the resource.
- Annotations Dictionary<string, string>
- Annotations of the resource.
- Folder
Uid string - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- Url string
- The full URL of the resource.
- Uuid string
- The globally unique identifier of a resource, used by the API for tracking.
- Version string
- The version of the resource.
- Uid string
- The unique identifier of the resource.
- Annotations map[string]string
- Annotations of the resource.
- Folder
Uid string - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- Url string
- The full URL of the resource.
- Uuid string
- The globally unique identifier of a resource, used by the API for tracking.
- Version string
- The version of the resource.
- uid string
- The unique identifier of the resource.
- annotations map(string)
- Annotations of the resource.
- folder_
uid string - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- url string
- The full URL of the resource.
- uuid string
- The globally unique identifier of a resource, used by the API for tracking.
- version string
- The version of the resource.
- uid String
- The unique identifier of the resource.
- annotations Map<String,String>
- Annotations of the resource.
- folder
Uid String - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- url String
- The full URL of the resource.
- uuid String
- The globally unique identifier of a resource, used by the API for tracking.
- version String
- The version of the resource.
- uid string
- The unique identifier of the resource.
- annotations {[key: string]: string}
- Annotations of the resource.
- folder
Uid string - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- url string
- The full URL of the resource.
- uuid string
- The globally unique identifier of a resource, used by the API for tracking.
- version string
- The version of the resource.
- uid str
- The unique identifier of the resource.
- annotations Mapping[str, str]
- Annotations of the resource.
- folder_
uid str - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- url str
- The full URL of the resource.
- uuid str
- The globally unique identifier of a resource, used by the API for tracking.
- version str
- The version of the resource.
- uid String
- The unique identifier of the resource.
- annotations Map<String>
- Annotations of the resource.
- folder
Uid String - The UID of the folder to save the resource in. For example, it's supported for dashboards and folders. To know if it's supported for the specific resource you're using check the documentation.
- url String
- The full URL of the resource.
- uuid String
- The globally unique identifier of a resource, used by the API for tracking.
- version String
- The version of the resource.
QueryOptions, QueryOptionsArgs
- Manager
Identity string - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- Overwrite bool
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- Manager
Identity string - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- Overwrite bool
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- manager_
identity string - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- overwrite bool
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- manager
Identity String - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- overwrite Boolean
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- manager
Identity string - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- overwrite boolean
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- manager_
identity str - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- overwrite bool
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
- manager
Identity String - Override the identity stamped on this resource's manager metadata. Defaults to "grafana-terraform-provider". Use this to distinguish resources managed by different Pulumi Stacks targeting the same Grafana instance.
- overwrite Boolean
- Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
QuerySpec, QuerySpecArgs
- Targets
List<Pulumiverse.
Grafana. Apps. V1. Inputs. Query Spec Target> - The query targets that make up the saved query. At least one target is required.
- Title string
- The display name of the saved query.
- Description string
- A longer description of the saved query.
- Is
Locked bool - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- Is
Visible bool - Whether the saved query is visible in the query library.
- List<string>
- The tags used to filter the saved query.
- Vars
List<Pulumiverse.
Grafana. Apps. V1. Inputs. Query Spec Var> - The template variables that can be interpolated into the query targets.
- Targets
[]Query
Spec Target - The query targets that make up the saved query. At least one target is required.
- Title string
- The display name of the saved query.
- Description string
- A longer description of the saved query.
- Is
Locked bool - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- Is
Visible bool - Whether the saved query is visible in the query library.
- []string
- The tags used to filter the saved query.
- Vars
[]Query
Spec Var - The template variables that can be interpolated into the query targets.
- targets list(object)
- The query targets that make up the saved query. At least one target is required.
- title string
- The display name of the saved query.
- description string
- A longer description of the saved query.
- is_
locked bool - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- is_
visible bool - Whether the saved query is visible in the query library.
- list(string)
- The tags used to filter the saved query.
- vars list(object)
- The template variables that can be interpolated into the query targets.
- targets
List<Query
Spec Target> - The query targets that make up the saved query. At least one target is required.
- title String
- The display name of the saved query.
- description String
- A longer description of the saved query.
- is
Locked Boolean - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- is
Visible Boolean - Whether the saved query is visible in the query library.
- List<String>
- The tags used to filter the saved query.
- vars
List<Query
Spec Var> - The template variables that can be interpolated into the query targets.
- targets
Query
Spec Target[] - The query targets that make up the saved query. At least one target is required.
- title string
- The display name of the saved query.
- description string
- A longer description of the saved query.
- is
Locked boolean - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- is
Visible boolean - Whether the saved query is visible in the query library.
- string[]
- The tags used to filter the saved query.
- vars
Query
Spec Var[] - The template variables that can be interpolated into the query targets.
- targets
Sequence[Query
Spec Target] - The query targets that make up the saved query. At least one target is required.
- title str
- The display name of the saved query.
- description str
- A longer description of the saved query.
- is_
locked bool - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- is_
visible bool - Whether the saved query is visible in the query library.
- Sequence[str]
- The tags used to filter the saved query.
- vars
Sequence[Query
Spec Var] - The template variables that can be interpolated into the query targets.
- targets List<Property Map>
- The query targets that make up the saved query. At least one target is required.
- title String
- The display name of the saved query.
- description String
- A longer description of the saved query.
- is
Locked Boolean - Whether the saved query is locked and cannot be edited in the UI. This is purely for UI display purposes and not for security.
- is
Visible Boolean - Whether the saved query is visible in the query library.
- List<String>
- The tags used to filter the saved query.
- vars List<Property Map>
- The template variables that can be interpolated into the query targets.
QuerySpecTarget, QuerySpecTargetArgs
- Properties
Json string - The datasource query for the target, as a JSON string (use jsonencode()).
- Data
Type string - The returned Dataplane frame type for the target.
- Variables
Json string - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- Properties
Json string - The datasource query for the target, as a JSON string (use jsonencode()).
- Data
Type string - The returned Dataplane frame type for the target.
- Variables
Json string - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- properties_
json string - The datasource query for the target, as a JSON string (use jsonencode()).
- data_
type string - The returned Dataplane frame type for the target.
- variables_
json string - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- properties
Json String - The datasource query for the target, as a JSON string (use jsonencode()).
- data
Type String - The returned Dataplane frame type for the target.
- variables
Json String - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- properties
Json string - The datasource query for the target, as a JSON string (use jsonencode()).
- data
Type string - The returned Dataplane frame type for the target.
- variables
Json string - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- properties_
json str - The datasource query for the target, as a JSON string (use jsonencode()).
- data_
type str - The returned Dataplane frame type for the target.
- variables_
json str - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
- properties
Json String - The datasource query for the target, as a JSON string (use jsonencode()).
- data
Type String - The returned Dataplane frame type for the target.
- variables
Json String - The variable replacements to apply to the target, as a JSON string (use jsonencode()).
QuerySpecVar, QuerySpecVarArgs
- Key string
- The name of the variable.
- Default
Values List<string> - The values used when no value is selected during render.
- Value
List stringDefinition Json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- Key string
- The name of the variable.
- Default
Values []string - The values used when no value is selected during render.
- Value
List stringDefinition Json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- key string
- The name of the variable.
- default_
values list(string) - The values used when no value is selected during render.
- value_
list_ stringdefinition_ json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- key String
- The name of the variable.
- default
Values List<String> - The values used when no value is selected during render.
- value
List StringDefinition Json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- key string
- The name of the variable.
- default
Values string[] - The values used when no value is selected during render.
- value
List stringDefinition Json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- key str
- The name of the variable.
- default_
values Sequence[str] - The values used when no value is selected during render.
- value_
list_ strdefinition_ json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
- key String
- The name of the variable.
- default
Values List<String> - The values used when no value is selected during render.
- value
List StringDefinition Json - The definition (as a JSON string) used by the frontend to fetch the list of selectable values.
Import
!/bin/bash Import an existing saved query by its UID
$ pulumi import grafana:apps/v1/query:Query example example-saved-query
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.
published on Friday, Aug 7, 2026 by pulumiverse