grafana.assert.CustomModelRules
Manages Asserts Custom Model Rules through the Grafana API.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const test = new grafana.assert.CustomModelRules("test", {
name: "test-anything",
rules: {
entities: [{
type: "Service",
name: "workload | service | job",
scope: {
namespace: "namespace",
env: "asserts_env",
site: "asserts_site",
},
lookup: {
workload: "workload | deployment | statefulset | daemonset | replicaset",
service: "service",
job: "job",
proxy_job: "job",
},
definedBies: [
{
query: "up{job!=''}",
disabled: false,
labelValues: {
service: "service",
job: "job",
},
literals: {
_source: "up_query",
},
},
{
query: "up{job='disabled'}",
disabled: true,
},
],
}],
},
});
import pulumi
import pulumiverse_grafana as grafana
test = grafana.assert_.CustomModelRules("test",
name="test-anything",
rules={
"entities": [{
"type": "Service",
"name": "workload | service | job",
"scope": {
"namespace": "namespace",
"env": "asserts_env",
"site": "asserts_site",
},
"lookup": {
"workload": "workload | deployment | statefulset | daemonset | replicaset",
"service": "service",
"job": "job",
"proxy_job": "job",
},
"defined_bies": [
{
"query": "up{job!=''}",
"disabled": False,
"label_values": {
"service": "service",
"job": "job",
},
"literals": {
"_source": "up_query",
},
},
{
"query": "up{job='disabled'}",
"disabled": True,
},
],
}],
})
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-grafana/sdk/v2/go/grafana/assert"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := assert.NewCustomModelRules(ctx, "test", &assert.CustomModelRulesArgs{
Name: pulumi.String("test-anything"),
Rules: &assert.CustomModelRulesRulesArgs{
Entities: assert.CustomModelRulesRulesEntityArray{
&assert.CustomModelRulesRulesEntityArgs{
Type: pulumi.String("Service"),
Name: pulumi.String("workload | service | job"),
Scope: pulumi.StringMap{
"namespace": pulumi.String("namespace"),
"env": pulumi.String("asserts_env"),
"site": pulumi.String("asserts_site"),
},
Lookup: pulumi.StringMap{
"workload": pulumi.String("workload | deployment | statefulset | daemonset | replicaset"),
"service": pulumi.String("service"),
"job": pulumi.String("job"),
"proxy_job": pulumi.String("job"),
},
DefinedBies: assert.CustomModelRulesRulesEntityDefinedByArray{
&assert.CustomModelRulesRulesEntityDefinedByArgs{
Query: pulumi.String("up{job!=''}"),
Disabled: pulumi.Bool(false),
LabelValues: pulumi.StringMap{
"service": pulumi.String("service"),
"job": pulumi.String("job"),
},
Literals: pulumi.StringMap{
"_source": pulumi.String("up_query"),
},
},
&assert.CustomModelRulesRulesEntityDefinedByArgs{
Query: pulumi.String("up{job='disabled'}"),
Disabled: pulumi.Bool(true),
},
},
},
},
},
})
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 test = new Grafana.Assert.CustomModelRules("test", new()
{
Name = "test-anything",
Rules = new Grafana.Assert.Inputs.CustomModelRulesRulesArgs
{
Entities = new[]
{
new Grafana.Assert.Inputs.CustomModelRulesRulesEntityArgs
{
Type = "Service",
Name = "workload | service | job",
Scope =
{
{ "namespace", "namespace" },
{ "env", "asserts_env" },
{ "site", "asserts_site" },
},
Lookup =
{
{ "workload", "workload | deployment | statefulset | daemonset | replicaset" },
{ "service", "service" },
{ "job", "job" },
{ "proxy_job", "job" },
},
DefinedBies = new[]
{
new Grafana.Assert.Inputs.CustomModelRulesRulesEntityDefinedByArgs
{
Query = "up{job!=''}",
Disabled = false,
LabelValues =
{
{ "service", "service" },
{ "job", "job" },
},
Literals =
{
{ "_source", "up_query" },
},
},
new Grafana.Assert.Inputs.CustomModelRulesRulesEntityDefinedByArgs
{
Query = "up{job='disabled'}",
Disabled = true,
},
},
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.assert.CustomModelRules;
import com.pulumi.grafana.assert.CustomModelRulesArgs;
import com.pulumi.grafana.assert.inputs.CustomModelRulesRulesArgs;
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 test = new CustomModelRules("test", CustomModelRulesArgs.builder()
.name("test-anything")
.rules(CustomModelRulesRulesArgs.builder()
.entities(CustomModelRulesRulesEntityArgs.builder()
.type("Service")
.name("workload | service | job")
.scope(Map.ofEntries(
Map.entry("namespace", "namespace"),
Map.entry("env", "asserts_env"),
Map.entry("site", "asserts_site")
))
.lookup(Map.ofEntries(
Map.entry("workload", "workload | deployment | statefulset | daemonset | replicaset"),
Map.entry("service", "service"),
Map.entry("job", "job"),
Map.entry("proxy_job", "job")
))
.definedBies(
CustomModelRulesRulesEntityDefinedByArgs.builder()
.query("up{job!=''}")
.disabled(false)
.labelValues(Map.ofEntries(
Map.entry("service", "service"),
Map.entry("job", "job")
))
.literals(Map.of("_source", "up_query"))
.build(),
CustomModelRulesRulesEntityDefinedByArgs.builder()
.query("up{job='disabled'}")
.disabled(true)
.build())
.build())
.build())
.build());
}
}
resources:
test:
type: grafana:assert:CustomModelRules
properties:
name: test-anything
rules:
entities:
- type: Service
name: workload | service | job
scope:
namespace: namespace
env: asserts_env
site: asserts_site
lookup:
workload: workload | deployment | statefulset | daemonset | replicaset
service: service
job: job
proxy_job: job
definedBies:
- query: up{job!=''}
disabled: false
labelValues:
service: service
job: job
literals:
_source: up_query
- query: up{job='disabled'}
disabled: true
Create CustomModelRules Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CustomModelRules(name: string, args: CustomModelRulesArgs, opts?: CustomResourceOptions);@overload
def CustomModelRules(resource_name: str,
args: CustomModelRulesArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CustomModelRules(resource_name: str,
opts: Optional[ResourceOptions] = None,
rules: Optional[CustomModelRulesRulesArgs] = None,
name: Optional[str] = None)func NewCustomModelRules(ctx *Context, name string, args CustomModelRulesArgs, opts ...ResourceOption) (*CustomModelRules, error)public CustomModelRules(string name, CustomModelRulesArgs args, CustomResourceOptions? opts = null)
public CustomModelRules(String name, CustomModelRulesArgs args)
public CustomModelRules(String name, CustomModelRulesArgs args, CustomResourceOptions options)
type: grafana:assert:CustomModelRules
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 CustomModelRulesArgs
- 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 CustomModelRulesArgs
- 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 CustomModelRulesArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CustomModelRulesArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CustomModelRulesArgs
- 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 customModelRulesResource = new Grafana.Assert.CustomModelRules("customModelRulesResource", new()
{
Rules = new Grafana.Assert.Inputs.CustomModelRulesRulesArgs
{
Entities = new[]
{
new Grafana.Assert.Inputs.CustomModelRulesRulesEntityArgs
{
DefinedBies = new[]
{
new Grafana.Assert.Inputs.CustomModelRulesRulesEntityDefinedByArgs
{
Query = "string",
Disabled = false,
LabelValues =
{
{ "string", "string" },
},
Literals =
{
{ "string", "string" },
},
MetricValue = "string",
},
},
Name = "string",
Type = "string",
Disabled = false,
EnrichedBies = new[]
{
"string",
},
Lookup =
{
{ "string", "string" },
},
Scope =
{
{ "string", "string" },
},
},
},
},
Name = "string",
});
example, err := assert.NewCustomModelRules(ctx, "customModelRulesResource", &assert.CustomModelRulesArgs{
Rules: &assert.CustomModelRulesRulesArgs{
Entities: assert.CustomModelRulesRulesEntityArray{
&assert.CustomModelRulesRulesEntityArgs{
DefinedBies: assert.CustomModelRulesRulesEntityDefinedByArray{
&assert.CustomModelRulesRulesEntityDefinedByArgs{
Query: pulumi.String("string"),
Disabled: pulumi.Bool(false),
LabelValues: pulumi.StringMap{
"string": pulumi.String("string"),
},
Literals: pulumi.StringMap{
"string": pulumi.String("string"),
},
MetricValue: pulumi.String("string"),
},
},
Name: pulumi.String("string"),
Type: pulumi.String("string"),
Disabled: pulumi.Bool(false),
EnrichedBies: pulumi.StringArray{
pulumi.String("string"),
},
Lookup: pulumi.StringMap{
"string": pulumi.String("string"),
},
Scope: pulumi.StringMap{
"string": pulumi.String("string"),
},
},
},
},
Name: pulumi.String("string"),
})
var customModelRulesResource = new CustomModelRules("customModelRulesResource", CustomModelRulesArgs.builder()
.rules(CustomModelRulesRulesArgs.builder()
.entities(CustomModelRulesRulesEntityArgs.builder()
.definedBies(CustomModelRulesRulesEntityDefinedByArgs.builder()
.query("string")
.disabled(false)
.labelValues(Map.of("string", "string"))
.literals(Map.of("string", "string"))
.metricValue("string")
.build())
.name("string")
.type("string")
.disabled(false)
.enrichedBies("string")
.lookup(Map.of("string", "string"))
.scope(Map.of("string", "string"))
.build())
.build())
.name("string")
.build());
custom_model_rules_resource = grafana.assert_.CustomModelRules("customModelRulesResource",
rules={
"entities": [{
"defined_bies": [{
"query": "string",
"disabled": False,
"label_values": {
"string": "string",
},
"literals": {
"string": "string",
},
"metric_value": "string",
}],
"name": "string",
"type": "string",
"disabled": False,
"enriched_bies": ["string"],
"lookup": {
"string": "string",
},
"scope": {
"string": "string",
},
}],
},
name="string")
const customModelRulesResource = new grafana.assert.CustomModelRules("customModelRulesResource", {
rules: {
entities: [{
definedBies: [{
query: "string",
disabled: false,
labelValues: {
string: "string",
},
literals: {
string: "string",
},
metricValue: "string",
}],
name: "string",
type: "string",
disabled: false,
enrichedBies: ["string"],
lookup: {
string: "string",
},
scope: {
string: "string",
},
}],
},
name: "string",
});
type: grafana:assert:CustomModelRules
properties:
name: string
rules:
entities:
- definedBies:
- disabled: false
labelValues:
string: string
literals:
string: string
metricValue: string
query: string
disabled: false
enrichedBies:
- string
lookup:
string: string
name: string
scope:
string: string
type: string
CustomModelRules 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 CustomModelRules resource accepts the following input properties:
- Rules
Pulumiverse.
Grafana. Assert. Inputs. Custom Model Rules Rules - The rules configuration for the custom model rules.
- Name string
- The name of the custom model rules.
- Rules
Custom
Model Rules Rules Args - The rules configuration for the custom model rules.
- Name string
- The name of the custom model rules.
- rules
Custom
Model Rules Rules - The rules configuration for the custom model rules.
- name String
- The name of the custom model rules.
- rules
Custom
Model Rules Rules - The rules configuration for the custom model rules.
- name string
- The name of the custom model rules.
- rules
Custom
Model Rules Rules Args - The rules configuration for the custom model rules.
- name str
- The name of the custom model rules.
- rules Property Map
- The rules configuration for the custom model rules.
- name String
- The name of the custom model rules.
Outputs
All input properties are implicitly available as output properties. Additionally, the CustomModelRules 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 CustomModelRules Resource
Get an existing CustomModelRules 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?: CustomModelRulesState, opts?: CustomResourceOptions): CustomModelRules@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
name: Optional[str] = None,
rules: Optional[CustomModelRulesRulesArgs] = None) -> CustomModelRulesfunc GetCustomModelRules(ctx *Context, name string, id IDInput, state *CustomModelRulesState, opts ...ResourceOption) (*CustomModelRules, error)public static CustomModelRules Get(string name, Input<string> id, CustomModelRulesState? state, CustomResourceOptions? opts = null)public static CustomModelRules get(String name, Output<String> id, CustomModelRulesState state, CustomResourceOptions options)resources: _: type: grafana:assert:CustomModelRules 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.
- Name string
- The name of the custom model rules.
- Rules
Pulumiverse.
Grafana. Assert. Inputs. Custom Model Rules Rules - The rules configuration for the custom model rules.
- Name string
- The name of the custom model rules.
- Rules
Custom
Model Rules Rules Args - The rules configuration for the custom model rules.
- name String
- The name of the custom model rules.
- rules
Custom
Model Rules Rules - The rules configuration for the custom model rules.
- name string
- The name of the custom model rules.
- rules
Custom
Model Rules Rules - The rules configuration for the custom model rules.
- name str
- The name of the custom model rules.
- rules
Custom
Model Rules Rules Args - The rules configuration for the custom model rules.
- name String
- The name of the custom model rules.
- rules Property Map
- The rules configuration for the custom model rules.
Supporting Types
CustomModelRulesRules, CustomModelRulesRulesArgs
- Entities
List<Pulumiverse.
Grafana. Assert. Inputs. Custom Model Rules Rules Entity> - List of entities to define in the custom model rules.
- Entities
[]Custom
Model Rules Rules Entity - List of entities to define in the custom model rules.
- entities
List<Custom
Model Rules Rules Entity> - List of entities to define in the custom model rules.
- entities
Custom
Model Rules Rules Entity[] - List of entities to define in the custom model rules.
- entities
Sequence[Custom
Model Rules Rules Entity] - List of entities to define in the custom model rules.
- entities List<Property Map>
- List of entities to define in the custom model rules.
CustomModelRulesRulesEntity, CustomModelRulesRulesEntityArgs
- Defined
Bies List<Pulumiverse.Grafana. Assert. Inputs. Custom Model Rules Rules Entity Defined By> - List of queries that define this entity.
- Name string
- The name of the entity.
- Type string
- The type of the entity (e.g., Service, Pod, Namespace).
- Disabled bool
- Whether this entity is disabled.
- Enriched
Bies List<string> - List of enrichment sources for the entity.
- Lookup Dictionary<string, string>
- Lookup mappings for the entity.
- Scope Dictionary<string, string>
- Scope labels for the entity.
- Defined
Bies []CustomModel Rules Rules Entity Defined By - List of queries that define this entity.
- Name string
- The name of the entity.
- Type string
- The type of the entity (e.g., Service, Pod, Namespace).
- Disabled bool
- Whether this entity is disabled.
- Enriched
Bies []string - List of enrichment sources for the entity.
- Lookup map[string]string
- Lookup mappings for the entity.
- Scope map[string]string
- Scope labels for the entity.
- defined
Bies List<CustomModel Rules Rules Entity Defined By> - List of queries that define this entity.
- name String
- The name of the entity.
- type String
- The type of the entity (e.g., Service, Pod, Namespace).
- disabled Boolean
- Whether this entity is disabled.
- enriched
Bies List<String> - List of enrichment sources for the entity.
- lookup Map<String,String>
- Lookup mappings for the entity.
- scope Map<String,String>
- Scope labels for the entity.
- defined
Bies CustomModel Rules Rules Entity Defined By[] - List of queries that define this entity.
- name string
- The name of the entity.
- type string
- The type of the entity (e.g., Service, Pod, Namespace).
- disabled boolean
- Whether this entity is disabled.
- enriched
Bies string[] - List of enrichment sources for the entity.
- lookup {[key: string]: string}
- Lookup mappings for the entity.
- scope {[key: string]: string}
- Scope labels for the entity.
- defined_
bies Sequence[CustomModel Rules Rules Entity Defined By] - List of queries that define this entity.
- name str
- The name of the entity.
- type str
- The type of the entity (e.g., Service, Pod, Namespace).
- disabled bool
- Whether this entity is disabled.
- enriched_
bies Sequence[str] - List of enrichment sources for the entity.
- lookup Mapping[str, str]
- Lookup mappings for the entity.
- scope Mapping[str, str]
- Scope labels for the entity.
- defined
Bies List<Property Map> - List of queries that define this entity.
- name String
- The name of the entity.
- type String
- The type of the entity (e.g., Service, Pod, Namespace).
- disabled Boolean
- Whether this entity is disabled.
- enriched
Bies List<String> - List of enrichment sources for the entity.
- lookup Map<String>
- Lookup mappings for the entity.
- scope Map<String>
- Scope labels for the entity.
CustomModelRulesRulesEntityDefinedBy, CustomModelRulesRulesEntityDefinedByArgs
- Query string
- The Prometheus query that defines this entity.
- Disabled bool
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- Label
Values Dictionary<string, string> - Label value mappings for the query.
- Literals Dictionary<string, string>
- Literal value mappings for the query.
- Metric
Value string - Metric value for the query.
- Query string
- The Prometheus query that defines this entity.
- Disabled bool
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- Label
Values map[string]string - Label value mappings for the query.
- Literals map[string]string
- Literal value mappings for the query.
- Metric
Value string - Metric value for the query.
- query String
- The Prometheus query that defines this entity.
- disabled Boolean
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- label
Values Map<String,String> - Label value mappings for the query.
- literals Map<String,String>
- Literal value mappings for the query.
- metric
Value String - Metric value for the query.
- query string
- The Prometheus query that defines this entity.
- disabled boolean
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- label
Values {[key: string]: string} - Label value mappings for the query.
- literals {[key: string]: string}
- Literal value mappings for the query.
- metric
Value string - Metric value for the query.
- query str
- The Prometheus query that defines this entity.
- disabled bool
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- label_
values Mapping[str, str] - Label value mappings for the query.
- literals Mapping[str, str]
- Literal value mappings for the query.
- metric_
value str - Metric value for the query.
- query String
- The Prometheus query that defines this entity.
- disabled Boolean
- Whether this rule is disabled. When true, only the 'query' field is used to match an existing rule to disable; other fields are ignored.
- label
Values Map<String> - Label value mappings for the query.
- literals Map<String>
- Literal value mappings for the query.
- metric
Value String - Metric value for the query.
Import
$ pulumi import grafana:assert/customModelRules:CustomModelRules name "{{ name }}"
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.
