1. Packages
  2. Dynatrace
  3. API Docs
  4. ServiceDetectionRules
Dynatrace v0.30.0 published on Friday, Jul 4, 2025 by Pulumiverse

dynatrace.ServiceDetectionRules

Explore with Pulumi AI

dynatrace logo
Dynatrace v0.30.0 published on Friday, Jul 4, 2025 by Pulumiverse

    This resource requires the API token scopes Read settings (settings.read) and Write settings (settings.write)

    Dynatrace Documentation

    • Services - https://docs.dynatrace.com/docs/observe/applications-and-microservices/services

    • Settings API - https://www.dynatrace.com/support/help/dynatrace-api/environment-api/settings (schemaId: builtin:service-detection-rules)

    Resource Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as dynatrace from "@pulumiverse/dynatrace";
    
    const _name_ = new dynatrace.ServiceDetectionRules("#name#", {
        enabled: false,
        rule: {
            additionalRequiredAttributes: [
                "attribute-1",
                "attribute-2",
            ],
            condition: "matchesValue(k8s.cluster.name,\"terraform\")",
            description: "Example description",
            ruleName: "#name#",
            serviceNameTemplate: "{k8s.workload.name}",
        },
        scope: "environment",
    });
    
    import pulumi
    import pulumiverse_dynatrace as dynatrace
    
    _name_ = dynatrace.ServiceDetectionRules("#name#",
        enabled=False,
        rule={
            "additional_required_attributes": [
                "attribute-1",
                "attribute-2",
            ],
            "condition": "matchesValue(k8s.cluster.name,\"terraform\")",
            "description": "Example description",
            "rule_name": "#name#",
            "service_name_template": "{k8s.workload.name}",
        },
        scope="environment")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-dynatrace/sdk/go/dynatrace"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := dynatrace.NewServiceDetectionRules(ctx, "#name#", &dynatrace.ServiceDetectionRulesArgs{
    			Enabled: pulumi.Bool(false),
    			Rule: &dynatrace.ServiceDetectionRulesRuleArgs{
    				AdditionalRequiredAttributes: pulumi.StringArray{
    					pulumi.String("attribute-1"),
    					pulumi.String("attribute-2"),
    				},
    				Condition:           pulumi.String("matchesValue(k8s.cluster.name,\"terraform\")"),
    				Description:         pulumi.String("Example description"),
    				RuleName:            pulumi.String("#name#"),
    				ServiceNameTemplate: pulumi.String("{k8s.workload.name}"),
    			},
    			Scope: pulumi.String("environment"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Dynatrace = Pulumiverse.Dynatrace;
    
    return await Deployment.RunAsync(() => 
    {
        var _name_ = new Dynatrace.ServiceDetectionRules("#name#", new()
        {
            Enabled = false,
            Rule = new Dynatrace.Inputs.ServiceDetectionRulesRuleArgs
            {
                AdditionalRequiredAttributes = new[]
                {
                    "attribute-1",
                    "attribute-2",
                },
                Condition = "matchesValue(k8s.cluster.name,\"terraform\")",
                Description = "Example description",
                RuleName = "#name#",
                ServiceNameTemplate = "{k8s.workload.name}",
            },
            Scope = "environment",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.dynatrace.ServiceDetectionRules;
    import com.pulumi.dynatrace.ServiceDetectionRulesArgs;
    import com.pulumi.dynatrace.inputs.ServiceDetectionRulesRuleArgs;
    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 _name_ = new ServiceDetectionRules("#name#", ServiceDetectionRulesArgs.builder()
                .enabled(false)
                .rule(ServiceDetectionRulesRuleArgs.builder()
                    .additionalRequiredAttributes(                
                        "attribute-1",
                        "attribute-2")
                    .condition("matchesValue(k8s.cluster.name,\"terraform\")")
                    .description("Example description")
                    .ruleName("#name#")
                    .serviceNameTemplate("{k8s.workload.name}")
                    .build())
                .scope("environment")
                .build());
    
        }
    }
    
    resources:
      '#name#':
        type: dynatrace:ServiceDetectionRules
        properties:
          enabled: false
          rule:
            additionalRequiredAttributes:
              - attribute-1
              - attribute-2
            condition: matchesValue(k8s.cluster.name,"terraform")
            description: Example description
            ruleName: '#name#'
            serviceNameTemplate: '{k8s.workload.name}'
          scope: environment
    

    Create ServiceDetectionRules Resource

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

    Constructor syntax

    new ServiceDetectionRules(name: string, args: ServiceDetectionRulesArgs, opts?: CustomResourceOptions);
    @overload
    def ServiceDetectionRules(resource_name: str,
                              args: ServiceDetectionRulesArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def ServiceDetectionRules(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              enabled: Optional[bool] = None,
                              rule: Optional[ServiceDetectionRulesRuleArgs] = None,
                              insert_after: Optional[str] = None,
                              scope: Optional[str] = None)
    func NewServiceDetectionRules(ctx *Context, name string, args ServiceDetectionRulesArgs, opts ...ResourceOption) (*ServiceDetectionRules, error)
    public ServiceDetectionRules(string name, ServiceDetectionRulesArgs args, CustomResourceOptions? opts = null)
    public ServiceDetectionRules(String name, ServiceDetectionRulesArgs args)
    public ServiceDetectionRules(String name, ServiceDetectionRulesArgs args, CustomResourceOptions options)
    
    type: dynatrace:ServiceDetectionRules
    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 ServiceDetectionRulesArgs
    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 ServiceDetectionRulesArgs
    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 ServiceDetectionRulesArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServiceDetectionRulesArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServiceDetectionRulesArgs
    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 serviceDetectionRulesResource = new Dynatrace.ServiceDetectionRules("serviceDetectionRulesResource", new()
    {
        Enabled = false,
        Rule = new Dynatrace.Inputs.ServiceDetectionRulesRuleArgs
        {
            RuleName = "string",
            ServiceNameTemplate = "string",
            AdditionalRequiredAttributes = new[]
            {
                "string",
            },
            Condition = "string",
            Description = "string",
        },
        InsertAfter = "string",
        Scope = "string",
    });
    
    example, err := dynatrace.NewServiceDetectionRules(ctx, "serviceDetectionRulesResource", &dynatrace.ServiceDetectionRulesArgs{
    	Enabled: pulumi.Bool(false),
    	Rule: &dynatrace.ServiceDetectionRulesRuleArgs{
    		RuleName:            pulumi.String("string"),
    		ServiceNameTemplate: pulumi.String("string"),
    		AdditionalRequiredAttributes: pulumi.StringArray{
    			pulumi.String("string"),
    		},
    		Condition:   pulumi.String("string"),
    		Description: pulumi.String("string"),
    	},
    	InsertAfter: pulumi.String("string"),
    	Scope:       pulumi.String("string"),
    })
    
    var serviceDetectionRulesResource = new ServiceDetectionRules("serviceDetectionRulesResource", ServiceDetectionRulesArgs.builder()
        .enabled(false)
        .rule(ServiceDetectionRulesRuleArgs.builder()
            .ruleName("string")
            .serviceNameTemplate("string")
            .additionalRequiredAttributes("string")
            .condition("string")
            .description("string")
            .build())
        .insertAfter("string")
        .scope("string")
        .build());
    
    service_detection_rules_resource = dynatrace.ServiceDetectionRules("serviceDetectionRulesResource",
        enabled=False,
        rule={
            "rule_name": "string",
            "service_name_template": "string",
            "additional_required_attributes": ["string"],
            "condition": "string",
            "description": "string",
        },
        insert_after="string",
        scope="string")
    
    const serviceDetectionRulesResource = new dynatrace.ServiceDetectionRules("serviceDetectionRulesResource", {
        enabled: false,
        rule: {
            ruleName: "string",
            serviceNameTemplate: "string",
            additionalRequiredAttributes: ["string"],
            condition: "string",
            description: "string",
        },
        insertAfter: "string",
        scope: "string",
    });
    
    type: dynatrace:ServiceDetectionRules
    properties:
        enabled: false
        insertAfter: string
        rule:
            additionalRequiredAttributes:
                - string
            condition: string
            description: string
            ruleName: string
            serviceNameTemplate: string
        scope: string
    

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

    Enabled bool
    This setting is enabled (true) or disabled (false)
    Rule Pulumiverse.Dynatrace.Inputs.ServiceDetectionRulesRule
    Rule
    InsertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    Scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    Enabled bool
    This setting is enabled (true) or disabled (false)
    Rule ServiceDetectionRulesRuleArgs
    Rule
    InsertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    Scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled Boolean
    This setting is enabled (true) or disabled (false)
    rule ServiceDetectionRulesRule
    Rule
    insertAfter String
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    scope String
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled boolean
    This setting is enabled (true) or disabled (false)
    rule ServiceDetectionRulesRule
    Rule
    insertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled bool
    This setting is enabled (true) or disabled (false)
    rule ServiceDetectionRulesRuleArgs
    Rule
    insert_after str
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    scope str
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled Boolean
    This setting is enabled (true) or disabled (false)
    rule Property Map
    Rule
    insertAfter String
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    scope String
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.

    Outputs

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

    Get an existing ServiceDetectionRules 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?: ServiceDetectionRulesState, opts?: CustomResourceOptions): ServiceDetectionRules
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            enabled: Optional[bool] = None,
            insert_after: Optional[str] = None,
            rule: Optional[ServiceDetectionRulesRuleArgs] = None,
            scope: Optional[str] = None) -> ServiceDetectionRules
    func GetServiceDetectionRules(ctx *Context, name string, id IDInput, state *ServiceDetectionRulesState, opts ...ResourceOption) (*ServiceDetectionRules, error)
    public static ServiceDetectionRules Get(string name, Input<string> id, ServiceDetectionRulesState? state, CustomResourceOptions? opts = null)
    public static ServiceDetectionRules get(String name, Output<String> id, ServiceDetectionRulesState state, CustomResourceOptions options)
    resources:  _:    type: dynatrace:ServiceDetectionRules    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:
    Enabled bool
    This setting is enabled (true) or disabled (false)
    InsertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    Rule Pulumiverse.Dynatrace.Inputs.ServiceDetectionRulesRule
    Rule
    Scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    Enabled bool
    This setting is enabled (true) or disabled (false)
    InsertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    Rule ServiceDetectionRulesRuleArgs
    Rule
    Scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled Boolean
    This setting is enabled (true) or disabled (false)
    insertAfter String
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    rule ServiceDetectionRulesRule
    Rule
    scope String
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled boolean
    This setting is enabled (true) or disabled (false)
    insertAfter string
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    rule ServiceDetectionRulesRule
    Rule
    scope string
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled bool
    This setting is enabled (true) or disabled (false)
    insert_after str
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    rule ServiceDetectionRulesRuleArgs
    Rule
    scope str
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.
    enabled Boolean
    This setting is enabled (true) or disabled (false)
    insertAfter String
    Because this resource allows for ordering you may specify the ID of the resource instance that comes before this instance regarding order. If not specified when creating the setting will be added to the end of the list. If not specified during update the order will remain untouched
    rule Property Map
    Rule
    scope String
    The scope of this setting (CLOUDAPPLICATIONNAMESPACE, KUBERNETESCLUSTER, HOSTGROUP). Omit this property if you want to cover the whole environment.

    Supporting Types

    ServiceDetectionRulesRule, ServiceDetectionRulesRuleArgs

    RuleName string
    Rule name
    ServiceNameTemplate string
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    AdditionalRequiredAttributes List<string>

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    Condition string

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    Description string
    no documentation available
    RuleName string
    Rule name
    ServiceNameTemplate string
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    AdditionalRequiredAttributes []string

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    Condition string

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    Description string
    no documentation available
    ruleName String
    Rule name
    serviceNameTemplate String
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    additionalRequiredAttributes List<String>

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    condition String

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    description String
    no documentation available
    ruleName string
    Rule name
    serviceNameTemplate string
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    additionalRequiredAttributes string[]

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    condition string

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    description string
    no documentation available
    rule_name str
    Rule name
    service_name_template str
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    additional_required_attributes Sequence[str]

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    condition str

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    description str
    no documentation available
    ruleName String
    Rule name
    serviceNameTemplate String
    Specify resource attribute placeholders in curly braces, e.g. {service.name} or {k8s.workload.name}.. All attributes used in the placeholder are required for the rule to apply. If any of them is missing, the rule will not be applied and ruleset evaluation continues.
    additionalRequiredAttributes List<String>

    Define resource attributes that should not be part of the name but are required to detect the service, e.g. service.namespace or k8s.workload.kind.. Attributes specified here are required to apply the rule. If any of them is missing, the rule will not be applied and ruleset evaluation continues.

    All attribute values contribute to the final service ID.

    condition String

    Limits the scope of the service detection rule using DQL matcher conditions on resource attributes.. A rule is applied only if the condition matches, otherwise the ruleset evaluation continues.

    If empty, the condition will always match.

    description String
    no documentation available

    Package Details

    Repository
    dynatrace pulumiverse/pulumi-dynatrace
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the dynatrace Terraform Provider.
    dynatrace logo
    Dynatrace v0.30.0 published on Friday, Jul 4, 2025 by Pulumiverse