SavedQuery class
Describes a query that has been saved by a user.
To get more information about SavedQuery, see:
- API documentation
- How-to Guides
- Official Documentation
- Save and share SQL queries
- Save and share queries
Example Usage
Logging Saved Query Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const savedQuery = new gcp.logging.SavedQuery("saved_query", {
name: "my-saved-query",
displayName: "My Saved Query",
parent: "projects/my-project-name",
location: "global",
description: "A saved query",
loggingQuery: {
filter: "resource.type=gce_instance",
},
visibility: "SHARED",
});
import pulumi
import pulumi_gcp as gcp
saved_query = gcp.logging.SavedQuery("saved_query",
name="my-saved-query",
display_name="My Saved Query",
parent="projects/my-project-name",
location="global",
description="A saved query",
logging_query={
"filter": "resource.type=gce_instance",
},
visibility="SHARED")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var savedQuery = new Gcp.Logging.SavedQuery("saved_query", new()
{
Name = "my-saved-query",
DisplayName = "My Saved Query",
Parent = "projects/my-project-name",
Location = "global",
Description = "A saved query",
LoggingQuery = new Gcp.Logging.Inputs.SavedQueryLoggingQueryArgs
{
Filter = "resource.type=gce_instance",
},
Visibility = "SHARED",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/logging"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := logging.NewSavedQuery(ctx, "saved_query", &logging.SavedQueryArgs{
Name: pulumi.String("my-saved-query"),
DisplayName: pulumi.String("My Saved Query"),
Parent: pulumi.String("projects/my-project-name"),
Location: pulumi.String("global"),
Description: pulumi.String("A saved query"),
LoggingQuery: &logging.SavedQueryLoggingQueryArgs{
Filter: pulumi.String("resource.type=gce_instance"),
},
Visibility: pulumi.String("SHARED"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_logging_savedquery" "saved_query" {
name = "my-saved-query"
display_name = "My Saved Query"
parent = "projects/my-project-name"
location = "global"
description = "A saved query"
logging_query = {
filter = "resource.type=gce_instance"
}
visibility = "SHARED"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.logging.SavedQuery;
import com.pulumi.gcp.logging.SavedQueryArgs;
import com.pulumi.gcp.logging.inputs.SavedQueryLoggingQueryArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 savedQuery = new SavedQuery("savedQuery", SavedQueryArgs.builder()
.name("my-saved-query")
.displayName("My Saved Query")
.parent("projects/my-project-name")
.location("global")
.description("A saved query")
.loggingQuery(SavedQueryLoggingQueryArgs.builder()
.filter("resource.type=gce_instance")
.build())
.visibility("SHARED")
.build());
}
}
resources:
savedQuery:
type: gcp:logging:SavedQuery
name: saved_query
properties:
name: my-saved-query
displayName: My Saved Query
parent: projects/my-project-name
location: global
description: A saved query
loggingQuery:
filter: resource.type=gce_instance
visibility: SHARED
Logging Saved Query Private
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const savedQuery = new gcp.logging.SavedQuery("saved_query", {
name: "my-saved-query-private",
displayName: "My Saved Query",
parent: "projects/my-project-name",
location: "global",
description: "A saved query",
loggingQuery: {
filter: "resource.type=gce_instance",
},
visibility: "PRIVATE",
});
import pulumi
import pulumi_gcp as gcp
saved_query = gcp.logging.SavedQuery("saved_query",
name="my-saved-query-private",
display_name="My Saved Query",
parent="projects/my-project-name",
location="global",
description="A saved query",
logging_query={
"filter": "resource.type=gce_instance",
},
visibility="PRIVATE")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var savedQuery = new Gcp.Logging.SavedQuery("saved_query", new()
{
Name = "my-saved-query-private",
DisplayName = "My Saved Query",
Parent = "projects/my-project-name",
Location = "global",
Description = "A saved query",
LoggingQuery = new Gcp.Logging.Inputs.SavedQueryLoggingQueryArgs
{
Filter = "resource.type=gce_instance",
},
Visibility = "PRIVATE",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/logging"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := logging.NewSavedQuery(ctx, "saved_query", &logging.SavedQueryArgs{
Name: pulumi.String("my-saved-query-private"),
DisplayName: pulumi.String("My Saved Query"),
Parent: pulumi.String("projects/my-project-name"),
Location: pulumi.String("global"),
Description: pulumi.String("A saved query"),
LoggingQuery: &logging.SavedQueryLoggingQueryArgs{
Filter: pulumi.String("resource.type=gce_instance"),
},
Visibility: pulumi.String("PRIVATE"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_logging_savedquery" "saved_query" {
name = "my-saved-query-private"
display_name = "My Saved Query"
parent = "projects/my-project-name"
location = "global"
description = "A saved query"
logging_query = {
filter = "resource.type=gce_instance"
}
visibility = "PRIVATE"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.logging.SavedQuery;
import com.pulumi.gcp.logging.SavedQueryArgs;
import com.pulumi.gcp.logging.inputs.SavedQueryLoggingQueryArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 savedQuery = new SavedQuery("savedQuery", SavedQueryArgs.builder()
.name("my-saved-query-private")
.displayName("My Saved Query")
.parent("projects/my-project-name")
.location("global")
.description("A saved query")
.loggingQuery(SavedQueryLoggingQueryArgs.builder()
.filter("resource.type=gce_instance")
.build())
.visibility("PRIVATE")
.build());
}
}
resources:
savedQuery:
type: gcp:logging:SavedQuery
name: saved_query
properties:
name: my-saved-query-private
displayName: My Saved Query
parent: projects/my-project-name
location: global
description: A saved query
loggingQuery:
filter: resource.type=gce_instance
visibility: PRIVATE
Logging Saved Query Summary Fields
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const savedQuery = new gcp.logging.SavedQuery("saved_query", {
name: "my-saved-query-summary-fields",
displayName: "My Saved Query",
parent: "projects/my-project-name",
location: "global",
description: "A saved query",
loggingQuery: {
filter: "resource.type=gce_instance",
summaryFields: [
{
field: "jsonPayload.paymentId",
},
{
field: "jsonPayload.errorMessage",
},
],
summaryFieldStart: 100,
},
visibility: "SHARED",
});
import pulumi
import pulumi_gcp as gcp
saved_query = gcp.logging.SavedQuery("saved_query",
name="my-saved-query-summary-fields",
display_name="My Saved Query",
parent="projects/my-project-name",
location="global",
description="A saved query",
logging_query={
"filter": "resource.type=gce_instance",
"summary_fields": [
{
"field": "jsonPayload.paymentId",
},
{
"field": "jsonPayload.errorMessage",
},
],
"summary_field_start": 100,
},
visibility="SHARED")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var savedQuery = new Gcp.Logging.SavedQuery("saved_query", new()
{
Name = "my-saved-query-summary-fields",
DisplayName = "My Saved Query",
Parent = "projects/my-project-name",
Location = "global",
Description = "A saved query",
LoggingQuery = new Gcp.Logging.Inputs.SavedQueryLoggingQueryArgs
{
Filter = "resource.type=gce_instance",
SummaryFields = new[]
{
new Gcp.Logging.Inputs.SavedQueryLoggingQuerySummaryFieldArgs
{
Field = "jsonPayload.paymentId",
},
new Gcp.Logging.Inputs.SavedQueryLoggingQuerySummaryFieldArgs
{
Field = "jsonPayload.errorMessage",
},
},
SummaryFieldStart = 100,
},
Visibility = "SHARED",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/logging"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := logging.NewSavedQuery(ctx, "saved_query", &logging.SavedQueryArgs{
Name: pulumi.String("my-saved-query-summary-fields"),
DisplayName: pulumi.String("My Saved Query"),
Parent: pulumi.String("projects/my-project-name"),
Location: pulumi.String("global"),
Description: pulumi.String("A saved query"),
LoggingQuery: &logging.SavedQueryLoggingQueryArgs{
Filter: pulumi.String("resource.type=gce_instance"),
SummaryFields: logging.SavedQueryLoggingQuerySummaryFieldArray{
&logging.SavedQueryLoggingQuerySummaryFieldArgs{
Field: pulumi.String("jsonPayload.paymentId"),
},
&logging.SavedQueryLoggingQuerySummaryFieldArgs{
Field: pulumi.String("jsonPayload.errorMessage"),
},
},
SummaryFieldStart: pulumi.Int(100),
},
Visibility: pulumi.String("SHARED"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_logging_savedquery" "saved_query" {
name = "my-saved-query-summary-fields"
display_name = "My Saved Query"
parent = "projects/my-project-name"
location = "global"
description = "A saved query"
logging_query = {
filter = "resource.type=gce_instance"
summary_fields = [{
"field" = "jsonPayload.paymentId"
}, {
"field" = "jsonPayload.errorMessage"
}]
summary_field_start = 100
}
# truncates after the first 100 characters
visibility = "SHARED"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.logging.SavedQuery;
import com.pulumi.gcp.logging.SavedQueryArgs;
import com.pulumi.gcp.logging.inputs.SavedQueryLoggingQueryArgs;
import com.pulumi.gcp.logging.inputs.SavedQueryLoggingQuerySummaryFieldArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 savedQuery = new SavedQuery("savedQuery", SavedQueryArgs.builder()
.name("my-saved-query-summary-fields")
.displayName("My Saved Query")
.parent("projects/my-project-name")
.location("global")
.description("A saved query")
.loggingQuery(SavedQueryLoggingQueryArgs.builder()
.filter("resource.type=gce_instance")
.summaryFields(
SavedQueryLoggingQuerySummaryFieldArgs.builder()
.field("jsonPayload.paymentId")
.build(),
SavedQueryLoggingQuerySummaryFieldArgs.builder()
.field("jsonPayload.errorMessage")
.build())
.summaryFieldStart(100)
.build())
.visibility("SHARED")
.build());
}
}
resources:
savedQuery:
type: gcp:logging:SavedQuery
name: saved_query
properties:
name: my-saved-query-summary-fields
displayName: My Saved Query
parent: projects/my-project-name
location: global
description: A saved query
loggingQuery:
filter: resource.type=gce_instance
summaryFields:
- field: jsonPayload.paymentId
- field: jsonPayload.errorMessage
summaryFieldStart: 100
visibility: SHARED
Logging Saved Query Sql Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const savedQuery = new gcp.logging.SavedQuery("saved_query", {
name: "my-saved-query-sql",
displayName: "My Saved Query",
parent: "projects/my-project-name",
location: "global",
description: "A saved query",
opsAnalyticsQuery: {
sqlQueryText: `SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
`,
},
visibility: "SHARED",
});
import pulumi
import pulumi_gcp as gcp
saved_query = gcp.logging.SavedQuery("saved_query",
name="my-saved-query-sql",
display_name="My Saved Query",
parent="projects/my-project-name",
location="global",
description="A saved query",
ops_analytics_query={
"sql_query_text": """SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
""",
},
visibility="SHARED")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var savedQuery = new Gcp.Logging.SavedQuery("saved_query", new()
{
Name = "my-saved-query-sql",
DisplayName = "My Saved Query",
Parent = "projects/my-project-name",
Location = "global",
Description = "A saved query",
OpsAnalyticsQuery = new Gcp.Logging.Inputs.SavedQueryOpsAnalyticsQueryArgs
{
SqlQueryText = @"SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
",
},
Visibility = "SHARED",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/logging"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := logging.NewSavedQuery(ctx, "saved_query", &logging.SavedQueryArgs{
Name: pulumi.String("my-saved-query-sql"),
DisplayName: pulumi.String("My Saved Query"),
Parent: pulumi.String("projects/my-project-name"),
Location: pulumi.String("global"),
Description: pulumi.String("A saved query"),
OpsAnalyticsQuery: &logging.SavedQueryOpsAnalyticsQueryArgs{
SqlQueryText: pulumi.String(`SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
`),
},
Visibility: pulumi.String("SHARED"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_logging_savedquery" "saved_query" {
name = "my-saved-query-sql"
display_name = "My Saved Query"
parent = "projects/my-project-name"
location = "global"
description = "A saved query"
ops_analytics_query = {
sql_query_text = "SELECT\n timestamp, log_name, severity, json_payload, resource, labels\nFROM\n VIEW\nWHERE\n timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)\nORDER BY timestamp ASC\nLIMIT 100\n"
}
visibility = "SHARED"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.logging.SavedQuery;
import com.pulumi.gcp.logging.SavedQueryArgs;
import com.pulumi.gcp.logging.inputs.SavedQueryOpsAnalyticsQueryArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 savedQuery = new SavedQuery("savedQuery", SavedQueryArgs.builder()
.name("my-saved-query-sql")
.displayName("My Saved Query")
.parent("projects/my-project-name")
.location("global")
.description("A saved query")
.opsAnalyticsQuery(SavedQueryOpsAnalyticsQueryArgs.builder()
.sqlQueryText("""
SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
""")
.build())
.visibility("SHARED")
.build());
}
}
resources:
savedQuery:
type: gcp:logging:SavedQuery
name: saved_query
properties:
name: my-saved-query-sql
displayName: My Saved Query
parent: projects/my-project-name
location: global
description: A saved query
opsAnalyticsQuery:
sqlQueryText: |
SELECT
timestamp, log_name, severity, json_payload, resource, labels
FROM
VIEW
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
ORDER BY timestamp ASC
LIMIT 100
visibility: SHARED
Import
SavedQuery can be imported using any of these accepted formats:
{{parent}}/locations/{{location}}/savedQueries/{{name}}
When using the pulumi import command, SavedQuery can be imported using one of the formats above. For example:
$ pulumi import gcp:logging/savedQuery:SavedQuery default {{parent}}/locations/{{location}}/savedQueries/{{name}}
Constructors
- SavedQuery(String name, {SavedQueryArgs? args, CustomResourceOptions? options})
-
Creates a new SavedQuery.
nameThe Pulumi resource name.argsArguments used to configure this SavedQuery. The set of arguments for SavedQuery.optionsResource options controlling this resource's behavior. - SavedQuery.reference(String urn)
- Creates a typed reference to an existing SavedQuery resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createTime
↔ Output<
String> -
Output only. The creation timestamp of the saved query.
latefinal
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
description
↔ Output<
String?> -
A description of the saved query.
latefinal
-
displayName
↔ Output<
String> -
The user-visible display name of the saved query.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
location
↔ Output<
String> -
The location of the resource see
supported regions.
latefinal
-
loggingQuery
↔ Output<
SavedQueryLoggingQuery?> -
The contents of the saved query.
Structure is documented below.
latefinal
-
name
↔ Output<
String> -
The name of the saved query. For example:
my-saved-querylatefinal -
opsAnalyticsQuery
↔ Output<
SavedQueryOpsAnalyticsQuery?> -
The contents of the saved query.
Structure is documented below.
latefinal
-
parent
↔ Output<
String> -
The parent of the resource.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
updateTime
↔ Output<
String> -
Output only. The last update timestamp of the saved query.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
-
visibility
↔ Output<
String> -
The visibility of the saved query.
Possible values are:
SHARED,PRIVATE.latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {SavedQueryState? state, CustomResourceOptions? options}) → SavedQuery -
Gets an existing SavedQuery resource's state with the given
nameandid.