alicloud.log.LogTailAttachment
Explore with Pulumi AI
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
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const _default = new random.RandomInteger("default", {
max: 99999,
min: 10000,
});
const exampleProject = new alicloud.log.Project("exampleProject", {description: "terraform-example"});
const exampleStore = new alicloud.log.Store("exampleStore", {
project: exampleProject.name,
retentionPeriod: 3650,
shardCount: 3,
autoSplit: true,
maxSplitShardCount: 60,
appendMeta: true,
});
const exampleLogTailConfig = new alicloud.log.LogTailConfig("exampleLogTailConfig", {
project: exampleProject.name,
logstore: exampleStore.name,
inputType: "file",
outputType: "LogService",
inputDetail: ` {
"logPath": "/logPath",
"filePattern": "access.log",
"logType": "json_log",
"topicFormat": "default",
"discardUnmatch": false,
"enableRawLog": true,
"fileEncoding": "gbk",
"maxDepth": 10
}
`,
});
const exampleMachineGroup = new alicloud.log.MachineGroup("exampleMachineGroup", {
project: exampleProject.name,
identifyType: "ip",
topic: "terraform",
identifyLists: [
"10.0.0.1",
"10.0.0.2",
],
});
const exampleLogTailAttachment = new alicloud.log.LogTailAttachment("exampleLogTailAttachment", {
project: exampleProject.name,
logtailConfigName: exampleLogTailConfig.name,
machineGroupName: exampleMachineGroup.name,
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
default = random.RandomInteger("default",
max=99999,
min=10000)
example_project = alicloud.log.Project("exampleProject", description="terraform-example")
example_store = alicloud.log.Store("exampleStore",
project=example_project.name,
retention_period=3650,
shard_count=3,
auto_split=True,
max_split_shard_count=60,
append_meta=True)
example_log_tail_config = alicloud.log.LogTailConfig("exampleLogTailConfig",
project=example_project.name,
logstore=example_store.name,
input_type="file",
output_type="LogService",
input_detail=""" {
"logPath": "/logPath",
"filePattern": "access.log",
"logType": "json_log",
"topicFormat": "default",
"discardUnmatch": false,
"enableRawLog": true,
"fileEncoding": "gbk",
"maxDepth": 10
}
""")
example_machine_group = alicloud.log.MachineGroup("exampleMachineGroup",
project=example_project.name,
identify_type="ip",
topic="terraform",
identify_lists=[
"10.0.0.1",
"10.0.0.2",
])
example_log_tail_attachment = alicloud.log.LogTailAttachment("exampleLogTailAttachment",
project=example_project.name,
logtail_config_name=example_log_tail_config.name,
machine_group_name=example_machine_group.name)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/log"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := random.NewRandomInteger(ctx, "default", &random.RandomIntegerArgs{
Max: pulumi.Int(99999),
Min: pulumi.Int(10000),
})
if err != nil {
return err
}
exampleProject, err := log.NewProject(ctx, "exampleProject", &log.ProjectArgs{
Description: pulumi.String("terraform-example"),
})
if err != nil {
return err
}
exampleStore, err := log.NewStore(ctx, "exampleStore", &log.StoreArgs{
Project: exampleProject.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
}
exampleLogTailConfig, err := log.NewLogTailConfig(ctx, "exampleLogTailConfig", &log.LogTailConfigArgs{
Project: exampleProject.Name,
Logstore: exampleStore.Name,
InputType: pulumi.String("file"),
OutputType: pulumi.String("LogService"),
InputDetail: pulumi.String(` {
"logPath": "/logPath",
"filePattern": "access.log",
"logType": "json_log",
"topicFormat": "default",
"discardUnmatch": false,
"enableRawLog": true,
"fileEncoding": "gbk",
"maxDepth": 10
}
`),
})
if err != nil {
return err
}
exampleMachineGroup, err := log.NewMachineGroup(ctx, "exampleMachineGroup", &log.MachineGroupArgs{
Project: exampleProject.Name,
IdentifyType: pulumi.String("ip"),
Topic: pulumi.String("terraform"),
IdentifyLists: pulumi.StringArray{
pulumi.String("10.0.0.1"),
pulumi.String("10.0.0.2"),
},
})
if err != nil {
return err
}
_, err = log.NewLogTailAttachment(ctx, "exampleLogTailAttachment", &log.LogTailAttachmentArgs{
Project: exampleProject.Name,
LogtailConfigName: exampleLogTailConfig.Name,
MachineGroupName: exampleMachineGroup.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var @default = new Random.RandomInteger("default", new()
{
Max = 99999,
Min = 10000,
});
var exampleProject = new AliCloud.Log.Project("exampleProject", new()
{
Description = "terraform-example",
});
var exampleStore = new AliCloud.Log.Store("exampleStore", new()
{
Project = exampleProject.Name,
RetentionPeriod = 3650,
ShardCount = 3,
AutoSplit = true,
MaxSplitShardCount = 60,
AppendMeta = true,
});
var exampleLogTailConfig = new AliCloud.Log.LogTailConfig("exampleLogTailConfig", new()
{
Project = exampleProject.Name,
Logstore = exampleStore.Name,
InputType = "file",
OutputType = "LogService",
InputDetail = @" {
""logPath"": ""/logPath"",
""filePattern"": ""access.log"",
""logType"": ""json_log"",
""topicFormat"": ""default"",
""discardUnmatch"": false,
""enableRawLog"": true,
""fileEncoding"": ""gbk"",
""maxDepth"": 10
}
",
});
var exampleMachineGroup = new AliCloud.Log.MachineGroup("exampleMachineGroup", new()
{
Project = exampleProject.Name,
IdentifyType = "ip",
Topic = "terraform",
IdentifyLists = new[]
{
"10.0.0.1",
"10.0.0.2",
},
});
var exampleLogTailAttachment = new AliCloud.Log.LogTailAttachment("exampleLogTailAttachment", new()
{
Project = exampleProject.Name,
LogtailConfigName = exampleLogTailConfig.Name,
MachineGroupName = exampleMachineGroup.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.RandomInteger;
import com.pulumi.random.RandomIntegerArgs;
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.LogTailConfig;
import com.pulumi.alicloud.log.LogTailConfigArgs;
import com.pulumi.alicloud.log.MachineGroup;
import com.pulumi.alicloud.log.MachineGroupArgs;
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 default_ = new RandomInteger("default", RandomIntegerArgs.builder()
.max(99999)
.min(10000)
.build());
var exampleProject = new Project("exampleProject", ProjectArgs.builder()
.description("terraform-example")
.build());
var exampleStore = new Store("exampleStore", StoreArgs.builder()
.project(exampleProject.name())
.retentionPeriod(3650)
.shardCount(3)
.autoSplit(true)
.maxSplitShardCount(60)
.appendMeta(true)
.build());
var exampleLogTailConfig = new LogTailConfig("exampleLogTailConfig", LogTailConfigArgs.builder()
.project(exampleProject.name())
.logstore(exampleStore.name())
.inputType("file")
.outputType("LogService")
.inputDetail("""
{
"logPath": "/logPath",
"filePattern": "access.log",
"logType": "json_log",
"topicFormat": "default",
"discardUnmatch": false,
"enableRawLog": true,
"fileEncoding": "gbk",
"maxDepth": 10
}
""")
.build());
var exampleMachineGroup = new MachineGroup("exampleMachineGroup", MachineGroupArgs.builder()
.project(exampleProject.name())
.identifyType("ip")
.topic("terraform")
.identifyLists(
"10.0.0.1",
"10.0.0.2")
.build());
var exampleLogTailAttachment = new LogTailAttachment("exampleLogTailAttachment", LogTailAttachmentArgs.builder()
.project(exampleProject.name())
.logtailConfigName(exampleLogTailConfig.name())
.machineGroupName(exampleMachineGroup.name())
.build());
}
}
resources:
default:
type: random:RandomInteger
properties:
max: 99999
min: 10000
exampleProject:
type: alicloud:log:Project
properties:
description: terraform-example
exampleStore:
type: alicloud:log:Store
properties:
project: ${exampleProject.name}
retentionPeriod: 3650
shardCount: 3
autoSplit: true
maxSplitShardCount: 60
appendMeta: true
exampleLogTailConfig:
type: alicloud:log:LogTailConfig
properties:
project: ${exampleProject.name}
logstore: ${exampleStore.name}
inputType: file
outputType: LogService
inputDetail: |2
{
"logPath": "/logPath",
"filePattern": "access.log",
"logType": "json_log",
"topicFormat": "default",
"discardUnmatch": false,
"enableRawLog": true,
"fileEncoding": "gbk",
"maxDepth": 10
}
exampleMachineGroup:
type: alicloud:log:MachineGroup
properties:
project: ${exampleProject.name}
identifyType: ip
topic: terraform
identifyLists:
- 10.0.0.1
- 10.0.0.2
exampleLogTailAttachment:
type: alicloud:log:LogTailAttachment
properties:
project: ${exampleProject.name}
logtailConfigName: ${exampleLogTailConfig.name}
machineGroupName: ${exampleMachineGroup.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:
- Logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- Machine
Group stringName - The machine group name, which is unique in the same project.
- Project string
- The project name to the log store belongs.
- Logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- Machine
Group stringName - The machine group name, which is unique in the same project.
- Project string
- The project name to the log store belongs.
- logtail
Config StringName - The Logtail configuration name, which is unique in the same project.
- machine
Group StringName - The machine group name, which is unique in the same project.
- project String
- The project name to the log store belongs.
- logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- machine
Group stringName - The machine group name, which is unique in the same project.
- project string
- The project name to the log store belongs.
- logtail_
config_ strname - The Logtail configuration name, which is unique in the same project.
- machine_
group_ strname - The machine group name, which is unique in the same project.
- project str
- The project name to the log store belongs.
- logtail
Config StringName - The Logtail configuration name, which is unique in the same project.
- machine
Group StringName - 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.
- Logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- Machine
Group stringName - The machine group name, which is unique in the same project.
- Project string
- The project name to the log store belongs.
- Logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- Machine
Group stringName - The machine group name, which is unique in the same project.
- Project string
- The project name to the log store belongs.
- logtail
Config StringName - The Logtail configuration name, which is unique in the same project.
- machine
Group StringName - The machine group name, which is unique in the same project.
- project String
- The project name to the log store belongs.
- logtail
Config stringName - The Logtail configuration name, which is unique in the same project.
- machine
Group stringName - The machine group name, which is unique in the same project.
- project string
- The project name to the log store belongs.
- logtail_
config_ strname - The Logtail configuration name, which is unique in the same project.
- machine_
group_ strname - The machine group name, which is unique in the same project.
- project str
- The project name to the log store belongs.
- logtail
Config StringName - The Logtail configuration name, which is unique in the same project.
- machine
Group StringName - 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
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.