Alibaba Cloud

v3.28.0 published on Tuesday, Aug 16, 2022 by Pulumi

LogTailAttachment

The Logtail access service is a log collection agent provided by Log Service. You can use Logtail to collect logs from servers such as Alibaba Cloud Elastic Compute Service (ECS) instances in real time in the Log Service console. Refer to details

This resource amis to attach one logtail configure to a machine group.

NOTE: One logtail configure can be attached to multiple machine groups and one machine group can attach several logtail configures.

Example Usage

Basic Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var testProject = new AliCloud.Log.Project("testProject", new AliCloud.Log.ProjectArgs
        {
            Description = "create by terraform",
        });
        var testStore = new AliCloud.Log.Store("testStore", new AliCloud.Log.StoreArgs
        {
            Project = testProject.Name,
            RetentionPeriod = 3650,
            ShardCount = 3,
            AutoSplit = true,
            MaxSplitShardCount = 60,
            AppendMeta = true,
        });
        var testMachineGroup = new AliCloud.Log.MachineGroup("testMachineGroup", new AliCloud.Log.MachineGroupArgs
        {
            Project = testProject.Name,
            Topic = "terraform",
            IdentifyLists = 
            {
                "10.0.0.1",
                "10.0.0.3",
                "10.0.0.2",
            },
        });
        var testLogTailConfig = new AliCloud.Log.LogTailConfig("testLogTailConfig", new AliCloud.Log.LogTailConfigArgs
        {
            Project = testProject.Name,
            Logstore = testStore.Name,
            InputType = "file",
            LogSample = "test",
            OutputType = "LogService",
            InputDetail = @"  	{
		""logPath"": ""/logPath"",
		""filePattern"": ""access.log"",
		""logType"": ""json_log"",
		""topicFormat"": ""default"",
		""discardUnmatch"": false,
		""enableRawLog"": true,
		""fileEncoding"": ""gbk"",
		""maxDepth"": 10
	}
	
",
        });
        var testLogTailAttachment = new AliCloud.Log.LogTailAttachment("testLogTailAttachment", new AliCloud.Log.LogTailAttachmentArgs
        {
            Project = testProject.Name,
            LogtailConfigName = testLogTailConfig.Name,
            MachineGroupName = testMachineGroup.Name,
        });
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/log"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testProject, err := log.NewProject(ctx, "testProject", &log.ProjectArgs{
			Description: pulumi.String("create by terraform"),
		})
		if err != nil {
			return err
		}
		testStore, err := log.NewStore(ctx, "testStore", &log.StoreArgs{
			Project:            testProject.Name,
			RetentionPeriod:    pulumi.Int(3650),
			ShardCount:         pulumi.Int(3),
			AutoSplit:          pulumi.Bool(true),
			MaxSplitShardCount: pulumi.Int(60),
			AppendMeta:         pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		testMachineGroup, err := log.NewMachineGroup(ctx, "testMachineGroup", &log.MachineGroupArgs{
			Project: testProject.Name,
			Topic:   pulumi.String("terraform"),
			IdentifyLists: pulumi.StringArray{
				pulumi.String("10.0.0.1"),
				pulumi.String("10.0.0.3"),
				pulumi.String("10.0.0.2"),
			},
		})
		if err != nil {
			return err
		}
		testLogTailConfig, err := log.NewLogTailConfig(ctx, "testLogTailConfig", &log.LogTailConfigArgs{
			Project:    testProject.Name,
			Logstore:   testStore.Name,
			InputType:  pulumi.String("file"),
			LogSample:  pulumi.String("test"),
			OutputType: pulumi.String("LogService"),
			InputDetail: pulumi.String(fmt.Sprintf(`  	{
		"logPath": "/logPath",
		"filePattern": "access.log",
		"logType": "json_log",
		"topicFormat": "default",
		"discardUnmatch": false,
		"enableRawLog": true,
		"fileEncoding": "gbk",
		"maxDepth": 10
	}
	
`)),
		})
		if err != nil {
			return err
		}
		_, err = log.NewLogTailAttachment(ctx, "testLogTailAttachment", &log.LogTailAttachmentArgs{
			Project:           testProject.Name,
			LogtailConfigName: testLogTailConfig.Name,
			MachineGroupName:  testMachineGroup.Name,
		})
		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.log.Project;
import com.pulumi.alicloud.log.ProjectArgs;
import com.pulumi.alicloud.log.Store;
import com.pulumi.alicloud.log.StoreArgs;
import com.pulumi.alicloud.log.MachineGroup;
import com.pulumi.alicloud.log.MachineGroupArgs;
import com.pulumi.alicloud.log.LogTailConfig;
import com.pulumi.alicloud.log.LogTailConfigArgs;
import com.pulumi.alicloud.log.LogTailAttachment;
import com.pulumi.alicloud.log.LogTailAttachmentArgs;
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 testProject = new Project("testProject", ProjectArgs.builder()        
            .description("create by terraform")
            .build());

        var testStore = new Store("testStore", StoreArgs.builder()        
            .project(testProject.name())
            .retentionPeriod(3650)
            .shardCount(3)
            .autoSplit(true)
            .maxSplitShardCount(60)
            .appendMeta(true)
            .build());

        var testMachineGroup = new MachineGroup("testMachineGroup", MachineGroupArgs.builder()        
            .project(testProject.name())
            .topic("terraform")
            .identifyLists(            
                "10.0.0.1",
                "10.0.0.3",
                "10.0.0.2")
            .build());

        var testLogTailConfig = new LogTailConfig("testLogTailConfig", LogTailConfigArgs.builder()        
            .project(testProject.name())
            .logstore(testStore.name())
            .inputType("file")
            .logSample("test")
            .outputType("LogService")
            .inputDetail("""
  	{
		"logPath": "/logPath",
		"filePattern": "access.log",
		"logType": "json_log",
		"topicFormat": "default",
		"discardUnmatch": false,
		"enableRawLog": true,
		"fileEncoding": "gbk",
		"maxDepth": 10
	}
	
            """)
            .build());

        var testLogTailAttachment = new LogTailAttachment("testLogTailAttachment", LogTailAttachmentArgs.builder()        
            .project(testProject.name())
            .logtailConfigName(testLogTailConfig.name())
            .machineGroupName(testMachineGroup.name())
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

test_project = alicloud.log.Project("testProject", description="create by terraform")
test_store = alicloud.log.Store("testStore",
    project=test_project.name,
    retention_period=3650,
    shard_count=3,
    auto_split=True,
    max_split_shard_count=60,
    append_meta=True)
test_machine_group = alicloud.log.MachineGroup("testMachineGroup",
    project=test_project.name,
    topic="terraform",
    identify_lists=[
        "10.0.0.1",
        "10.0.0.3",
        "10.0.0.2",
    ])
test_log_tail_config = alicloud.log.LogTailConfig("testLogTailConfig",
    project=test_project.name,
    logstore=test_store.name,
    input_type="file",
    log_sample="test",
    output_type="LogService",
    input_detail="""  	{
		"logPath": "/logPath",
		"filePattern": "access.log",
		"logType": "json_log",
		"topicFormat": "default",
		"discardUnmatch": false,
		"enableRawLog": true,
		"fileEncoding": "gbk",
		"maxDepth": 10
	}
	
""")
test_log_tail_attachment = alicloud.log.LogTailAttachment("testLogTailAttachment",
    project=test_project.name,
    logtail_config_name=test_log_tail_config.name,
    machine_group_name=test_machine_group.name)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const testProject = new alicloud.log.Project("testProject", {description: "create by terraform"});
const testStore = new alicloud.log.Store("testStore", {
    project: testProject.name,
    retentionPeriod: 3650,
    shardCount: 3,
    autoSplit: true,
    maxSplitShardCount: 60,
    appendMeta: true,
});
const testMachineGroup = new alicloud.log.MachineGroup("testMachineGroup", {
    project: testProject.name,
    topic: "terraform",
    identifyLists: [
        "10.0.0.1",
        "10.0.0.3",
        "10.0.0.2",
    ],
});
const testLogTailConfig = new alicloud.log.LogTailConfig("testLogTailConfig", {
    project: testProject.name,
    logstore: testStore.name,
    inputType: "file",
    logSample: "test",
    outputType: "LogService",
    inputDetail: `  	{
		"logPath": "/logPath",
		"filePattern": "access.log",
		"logType": "json_log",
		"topicFormat": "default",
		"discardUnmatch": false,
		"enableRawLog": true,
		"fileEncoding": "gbk",
		"maxDepth": 10
	}
	
`,
});
const testLogTailAttachment = new alicloud.log.LogTailAttachment("testLogTailAttachment", {
    project: testProject.name,
    logtailConfigName: testLogTailConfig.name,
    machineGroupName: testMachineGroup.name,
});
resources:
  testProject:
    type: alicloud:log:Project
    properties:
      description: create by terraform
  testStore:
    type: alicloud:log:Store
    properties:
      project: ${testProject.name}
      retentionPeriod: 3650
      shardCount: 3
      autoSplit: true
      maxSplitShardCount: 60
      appendMeta: true
  testMachineGroup:
    type: alicloud:log:MachineGroup
    properties:
      project: ${testProject.name}
      topic: terraform
      identifyLists:
        - 10.0.0.1
        - 10.0.0.3
        - 10.0.0.2
  testLogTailConfig:
    type: alicloud:log:LogTailConfig
    properties:
      project: ${testProject.name}
      logstore: ${testStore.name}
      inputType: file
      logSample: test
      outputType: LogService
      inputDetail: |2
          	{
        		"logPath": "/logPath",
        		"filePattern": "access.log",
        		"logType": "json_log",
        		"topicFormat": "default",
        		"discardUnmatch": false,
        		"enableRawLog": true,
        		"fileEncoding": "gbk",
        		"maxDepth": 10
        	}
        	
  testLogTailAttachment:
    type: alicloud:log:LogTailAttachment
    properties:
      project: ${testProject.name}
      logtailConfigName: ${testLogTailConfig.name}
      machineGroupName: ${testMachineGroup.name}

Create LogTailAttachment Resource

new LogTailAttachment(name: string, args: LogTailAttachmentArgs, opts?: CustomResourceOptions);
@overload
def LogTailAttachment(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      logtail_config_name: Optional[str] = None,
                      machine_group_name: Optional[str] = None,
                      project: Optional[str] = None)
@overload
def LogTailAttachment(resource_name: str,
                      args: LogTailAttachmentArgs,
                      opts: Optional[ResourceOptions] = None)
func NewLogTailAttachment(ctx *Context, name string, args LogTailAttachmentArgs, opts ...ResourceOption) (*LogTailAttachment, error)
public LogTailAttachment(string name, LogTailAttachmentArgs args, CustomResourceOptions? opts = null)
public LogTailAttachment(String name, LogTailAttachmentArgs args)
public LogTailAttachment(String name, LogTailAttachmentArgs args, CustomResourceOptions options)
type: alicloud:log:LogTailAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args LogTailAttachmentArgs
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 LogTailAttachmentArgs
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 LogTailAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LogTailAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args LogTailAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

LogtailConfigName string

The Logtail configuration name, which is unique in the same project.

MachineGroupName string

The machine group name, which is unique in the same project.

Project string

The project name to the log store belongs.

LogtailConfigName string

The Logtail configuration name, which is unique in the same project.

MachineGroupName string

The machine group name, which is unique in the same project.

Project string

The project name to the log store belongs.

logtailConfigName String

The Logtail configuration name, which is unique in the same project.

machineGroupName String

The machine group name, which is unique in the same project.

project String

The project name to the log store belongs.

logtailConfigName string

The Logtail configuration name, which is unique in the same project.

machineGroupName string

The machine group name, which is unique in the same project.

project string

The project name to the log store belongs.

logtail_config_name str

The Logtail configuration name, which is unique in the same project.

machine_group_name str

The machine group name, which is unique in the same project.

project str

The project name to the log store belongs.

logtailConfigName String

The Logtail configuration name, which is unique in the same project.

machineGroupName String

The machine group name, which is unique in the same project.

project String

The project name to the log store belongs.

Outputs

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

Get an existing LogTailAttachment 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?: LogTailAttachmentState, opts?: CustomResourceOptions): LogTailAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        logtail_config_name: Optional[str] = None,
        machine_group_name: Optional[str] = None,
        project: Optional[str] = None) -> LogTailAttachment
func GetLogTailAttachment(ctx *Context, name string, id IDInput, state *LogTailAttachmentState, opts ...ResourceOption) (*LogTailAttachment, error)
public static LogTailAttachment Get(string name, Input<string> id, LogTailAttachmentState? state, CustomResourceOptions? opts = null)
public static LogTailAttachment get(String name, Output<String> id, LogTailAttachmentState 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:
LogtailConfigName string

The Logtail configuration name, which is unique in the same project.

MachineGroupName string

The machine group name, which is unique in the same project.

Project string

The project name to the log store belongs.

LogtailConfigName string

The Logtail configuration name, which is unique in the same project.

MachineGroupName string

The machine group name, which is unique in the same project.

Project string

The project name to the log store belongs.

logtailConfigName String

The Logtail configuration name, which is unique in the same project.

machineGroupName String

The machine group name, which is unique in the same project.

project String

The project name to the log store belongs.

logtailConfigName string

The Logtail configuration name, which is unique in the same project.

machineGroupName string

The machine group name, which is unique in the same project.

project string

The project name to the log store belongs.

logtail_config_name str

The Logtail configuration name, which is unique in the same project.

machine_group_name str

The machine group name, which is unique in the same project.

project str

The project name to the log store belongs.

logtailConfigName String

The Logtail configuration name, which is unique in the same project.

machineGroupName String

The machine group name, which is unique in the same project.

project String

The project name to the log store belongs.

Import

Logtial to machine group can be imported using the id, e.g.

 $ pulumi import alicloud:log/logTailAttachment:LogTailAttachment example tf-log:tf-log-config:tf-log-machine-group

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.