1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. arms
  5. RemoteWrite
Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi

alicloud.arms.RemoteWrite

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi

    Provides a Application Real-Time Monitoring Service (ARMS) Remote Write resource.

    For information about Application Real-Time Monitoring Service (ARMS) Remote Write and how to use it, see What is Remote Write.

    NOTE: Available since v1.204.0.

    Example Usage

    Basic Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "tf-example";
        var defaultZones = AliCloud.GetZones.Invoke(new()
        {
            AvailableResourceCreation = "VSwitch",
        });
    
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
        {
            VpcName = name,
            CidrBlock = "10.4.0.0/16",
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
        {
            VswitchName = name,
            CidrBlock = "10.4.0.0/24",
            VpcId = defaultNetwork.Id,
            ZoneId = Output.Tuple(defaultZones, defaultZones.Apply(getZonesResult => getZonesResult.Zones).Length).Apply(values =>
            {
                var defaultZones = values.Item1;
                var length = values.Item2;
                return defaultZones.Apply(getZonesResult => getZonesResult.Zones)[length - 1].Id;
            }),
        });
    
        var defaultSecurityGroup = new AliCloud.Ecs.SecurityGroup("defaultSecurityGroup", new()
        {
            VpcId = defaultNetwork.Id,
        });
    
        var defaultResourceGroups = AliCloud.ResourceManager.GetResourceGroups.Invoke();
    
        var defaultPrometheus = new AliCloud.Arms.Prometheus("defaultPrometheus", new()
        {
            ClusterType = "ecs",
            GrafanaInstanceId = "free",
            VpcId = defaultNetwork.Id,
            VswitchId = defaultSwitch.Id,
            SecurityGroupId = defaultSecurityGroup.Id,
            ClusterName = defaultNetwork.Id.Apply(id => $"{name}-{id}"),
            ResourceGroupId = defaultResourceGroups.Apply(getResourceGroupsResult => getResourceGroupsResult.Groups[0]?.Id),
            Tags = 
            {
                { "Created", "TF" },
                { "For", "Prometheus" },
            },
        });
    
        var defaultRemoteWrite = new AliCloud.Arms.RemoteWrite("defaultRemoteWrite", new()
        {
            ClusterId = defaultPrometheus.Id,
            RemoteWriteYaml = @"remote_write:
    - name: ArmsRemoteWrite
      url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write
      basic_auth: {username: 666, password: '******'}
      write_relabel_configs:
      - source_labels: [instance_id]
        separator: ;
        regex: si-6e2ca86444db4e55a7c1
        replacement: $1
        action: keep
    ",
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/arms"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "tf-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
    			AvailableResourceCreation: pulumi.StringRef("VSwitch"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
    			VpcName:   pulumi.String(name),
    			CidrBlock: pulumi.String("10.4.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
    			VswitchName: pulumi.String(name),
    			CidrBlock:   pulumi.String("10.4.0.0/24"),
    			VpcId:       defaultNetwork.ID(),
    			ZoneId:      defaultZones.Zones[len(defaultZones.Zones)-1].Id,
    		})
    		if err != nil {
    			return err
    		}
    		defaultSecurityGroup, err := ecs.NewSecurityGroup(ctx, "defaultSecurityGroup", &ecs.SecurityGroupArgs{
    			VpcId: defaultNetwork.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		defaultResourceGroups, err := resourcemanager.GetResourceGroups(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultPrometheus, err := arms.NewPrometheus(ctx, "defaultPrometheus", &arms.PrometheusArgs{
    			ClusterType:       pulumi.String("ecs"),
    			GrafanaInstanceId: pulumi.String("free"),
    			VpcId:             defaultNetwork.ID(),
    			VswitchId:         defaultSwitch.ID(),
    			SecurityGroupId:   defaultSecurityGroup.ID(),
    			ClusterName: defaultNetwork.ID().ApplyT(func(id string) (string, error) {
    				return fmt.Sprintf("%v-%v", name, id), nil
    			}).(pulumi.StringOutput),
    			ResourceGroupId: *pulumi.String(defaultResourceGroups.Groups[0].Id),
    			Tags: pulumi.Map{
    				"Created": pulumi.Any("TF"),
    				"For":     pulumi.Any("Prometheus"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = arms.NewRemoteWrite(ctx, "defaultRemoteWrite", &arms.RemoteWriteArgs{
    			ClusterId: defaultPrometheus.ID(),
    			RemoteWriteYaml: pulumi.String(`remote_write:
    - name: ArmsRemoteWrite
      url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write
      basic_auth: {username: 666, password: '******'}
      write_relabel_configs:
      - source_labels: [instance_id]
        separator: ;
        regex: si-6e2ca86444db4e55a7c1
        replacement: $1
        action: keep
    `),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.AlicloudFunctions;
    import com.pulumi.alicloud.inputs.GetZonesArgs;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.vpc.Switch;
    import com.pulumi.alicloud.vpc.SwitchArgs;
    import com.pulumi.alicloud.ecs.SecurityGroup;
    import com.pulumi.alicloud.ecs.SecurityGroupArgs;
    import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
    import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
    import com.pulumi.alicloud.arms.Prometheus;
    import com.pulumi.alicloud.arms.PrometheusArgs;
    import com.pulumi.alicloud.arms.RemoteWrite;
    import com.pulumi.alicloud.arms.RemoteWriteArgs;
    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) {
            final var config = ctx.config();
            final var name = config.get("name").orElse("tf-example");
            final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
                .availableResourceCreation("VSwitch")
                .build());
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
                .vpcName(name)
                .cidrBlock("10.4.0.0/16")
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
                .vswitchName(name)
                .cidrBlock("10.4.0.0/24")
                .vpcId(defaultNetwork.id())
                .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones())[defaultZones.applyValue(getZonesResult -> getZonesResult.zones()).length() - 1].id())
                .build());
    
            var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()        
                .vpcId(defaultNetwork.id())
                .build());
    
            final var defaultResourceGroups = ResourcemanagerFunctions.getResourceGroups();
    
            var defaultPrometheus = new Prometheus("defaultPrometheus", PrometheusArgs.builder()        
                .clusterType("ecs")
                .grafanaInstanceId("free")
                .vpcId(defaultNetwork.id())
                .vswitchId(defaultSwitch.id())
                .securityGroupId(defaultSecurityGroup.id())
                .clusterName(defaultNetwork.id().applyValue(id -> String.format("%s-%s", name,id)))
                .resourceGroupId(defaultResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.groups()[0].id()))
                .tags(Map.ofEntries(
                    Map.entry("Created", "TF"),
                    Map.entry("For", "Prometheus")
                ))
                .build());
    
            var defaultRemoteWrite = new RemoteWrite("defaultRemoteWrite", RemoteWriteArgs.builder()        
                .clusterId(defaultPrometheus.id())
                .remoteWriteYaml("""
    remote_write:
    - name: ArmsRemoteWrite
      url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write
      basic_auth: {username: 666, password: '******'}
      write_relabel_configs:
      - source_labels: [instance_id]
        separator: ;
        regex: si-6e2ca86444db4e55a7c1
        replacement: $1
        action: keep
                """)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf-example"
    default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
    default_network = alicloud.vpc.Network("defaultNetwork",
        vpc_name=name,
        cidr_block="10.4.0.0/16")
    default_switch = alicloud.vpc.Switch("defaultSwitch",
        vswitch_name=name,
        cidr_block="10.4.0.0/24",
        vpc_id=default_network.id,
        zone_id=default_zones.zones[len(default_zones.zones) - 1].id)
    default_security_group = alicloud.ecs.SecurityGroup("defaultSecurityGroup", vpc_id=default_network.id)
    default_resource_groups = alicloud.resourcemanager.get_resource_groups()
    default_prometheus = alicloud.arms.Prometheus("defaultPrometheus",
        cluster_type="ecs",
        grafana_instance_id="free",
        vpc_id=default_network.id,
        vswitch_id=default_switch.id,
        security_group_id=default_security_group.id,
        cluster_name=default_network.id.apply(lambda id: f"{name}-{id}"),
        resource_group_id=default_resource_groups.groups[0].id,
        tags={
            "Created": "TF",
            "For": "Prometheus",
        })
    default_remote_write = alicloud.arms.RemoteWrite("defaultRemoteWrite",
        cluster_id=default_prometheus.id,
        remote_write_yaml="""remote_write:
    - name: ArmsRemoteWrite
      url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write
      basic_auth: {username: 666, password: '******'}
      write_relabel_configs:
      - source_labels: [instance_id]
        separator: ;
        regex: si-6e2ca86444db4e55a7c1
        replacement: $1
        action: keep
    """)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "tf-example";
    const defaultZones = alicloud.getZones({
        availableResourceCreation: "VSwitch",
    });
    const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
        vpcName: name,
        cidrBlock: "10.4.0.0/16",
    });
    const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
        vswitchName: name,
        cidrBlock: "10.4.0.0/24",
        vpcId: defaultNetwork.id,
        zoneId: Promise.all([defaultZones, defaultZones.then(defaultZones => defaultZones.zones).length]).then(([defaultZones, length]) => defaultZones.zones[length - 1].id),
    });
    const defaultSecurityGroup = new alicloud.ecs.SecurityGroup("defaultSecurityGroup", {vpcId: defaultNetwork.id});
    const defaultResourceGroups = alicloud.resourcemanager.getResourceGroups({});
    const defaultPrometheus = new alicloud.arms.Prometheus("defaultPrometheus", {
        clusterType: "ecs",
        grafanaInstanceId: "free",
        vpcId: defaultNetwork.id,
        vswitchId: defaultSwitch.id,
        securityGroupId: defaultSecurityGroup.id,
        clusterName: pulumi.interpolate`${name}-${defaultNetwork.id}`,
        resourceGroupId: defaultResourceGroups.then(defaultResourceGroups => defaultResourceGroups.groups?.[0]?.id),
        tags: {
            Created: "TF",
            For: "Prometheus",
        },
    });
    const defaultRemoteWrite = new alicloud.arms.RemoteWrite("defaultRemoteWrite", {
        clusterId: defaultPrometheus.id,
        remoteWriteYaml: `remote_write:
    - name: ArmsRemoteWrite
      url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write
      basic_auth: {username: 666, password: '******'}
      write_relabel_configs:
      - source_labels: [instance_id]
        separator: ;
        regex: si-6e2ca86444db4e55a7c1
        replacement: $1
        action: keep
    `,
    });
    

    Coming soon!

    Create RemoteWrite Resource

    new RemoteWrite(name: string, args: RemoteWriteArgs, opts?: CustomResourceOptions);
    @overload
    def RemoteWrite(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    cluster_id: Optional[str] = None,
                    remote_write_yaml: Optional[str] = None)
    @overload
    def RemoteWrite(resource_name: str,
                    args: RemoteWriteArgs,
                    opts: Optional[ResourceOptions] = None)
    func NewRemoteWrite(ctx *Context, name string, args RemoteWriteArgs, opts ...ResourceOption) (*RemoteWrite, error)
    public RemoteWrite(string name, RemoteWriteArgs args, CustomResourceOptions? opts = null)
    public RemoteWrite(String name, RemoteWriteArgs args)
    public RemoteWrite(String name, RemoteWriteArgs args, CustomResourceOptions options)
    
    type: alicloud:arms:RemoteWrite
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args RemoteWriteArgs
    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 RemoteWriteArgs
    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 RemoteWriteArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RemoteWriteArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RemoteWriteArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    RemoteWrite Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The RemoteWrite resource accepts the following input properties:

    ClusterId string

    The ID of the Prometheus instance.

    RemoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    ClusterId string

    The ID of the Prometheus instance.

    RemoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId String

    The ID of the Prometheus instance.

    remoteWriteYaml String

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId string

    The ID of the Prometheus instance.

    remoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    cluster_id str

    The ID of the Prometheus instance.

    remote_write_yaml str

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId String

    The ID of the Prometheus instance.

    remoteWriteYaml String

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RemoteWrite resource produces the following output properties:

    Id string

    The provider-assigned unique ID for this managed resource.

    RemoteWriteName string

    The name of the Remote Write configuration item.

    Id string

    The provider-assigned unique ID for this managed resource.

    RemoteWriteName string

    The name of the Remote Write configuration item.

    id String

    The provider-assigned unique ID for this managed resource.

    remoteWriteName String

    The name of the Remote Write configuration item.

    id string

    The provider-assigned unique ID for this managed resource.

    remoteWriteName string

    The name of the Remote Write configuration item.

    id str

    The provider-assigned unique ID for this managed resource.

    remote_write_name str

    The name of the Remote Write configuration item.

    id String

    The provider-assigned unique ID for this managed resource.

    remoteWriteName String

    The name of the Remote Write configuration item.

    Look up Existing RemoteWrite Resource

    Get an existing RemoteWrite 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?: RemoteWriteState, opts?: CustomResourceOptions): RemoteWrite
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cluster_id: Optional[str] = None,
            remote_write_name: Optional[str] = None,
            remote_write_yaml: Optional[str] = None) -> RemoteWrite
    func GetRemoteWrite(ctx *Context, name string, id IDInput, state *RemoteWriteState, opts ...ResourceOption) (*RemoteWrite, error)
    public static RemoteWrite Get(string name, Input<string> id, RemoteWriteState? state, CustomResourceOptions? opts = null)
    public static RemoteWrite get(String name, Output<String> id, RemoteWriteState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    ClusterId string

    The ID of the Prometheus instance.

    RemoteWriteName string

    The name of the Remote Write configuration item.

    RemoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    ClusterId string

    The ID of the Prometheus instance.

    RemoteWriteName string

    The name of the Remote Write configuration item.

    RemoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId String

    The ID of the Prometheus instance.

    remoteWriteName String

    The name of the Remote Write configuration item.

    remoteWriteYaml String

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId string

    The ID of the Prometheus instance.

    remoteWriteName string

    The name of the Remote Write configuration item.

    remoteWriteYaml string

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    cluster_id str

    The ID of the Prometheus instance.

    remote_write_name str

    The name of the Remote Write configuration item.

    remote_write_yaml str

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    clusterId String

    The ID of the Prometheus instance.

    remoteWriteName String

    The name of the Remote Write configuration item.

    remoteWriteYaml String

    The details of the Remote Write configuration item. Specify the value in the YAML format.

    Import

    Application Real-Time Monitoring Service (ARMS) Remote Write can be imported using the id, e.g.

     $ pulumi import alicloud:arms/remoteWrite:RemoteWrite example <cluster_id>:<remote_write_name>
    

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the alicloud Terraform Provider.

    alicloud logo
    Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi