-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocessor.tf
More file actions
82 lines (73 loc) · 2.18 KB
/
processor.tf
File metadata and controls
82 lines (73 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// The cloudwatch log group name is used as the "service" in datadog
// This pipeline will:
// - Set the block name based on this log group
// - Remap the service name to this block name
// - Extract the container name from the log stream name
// - Extract the task id from the log stream name
resource "datadog_logs_custom_pipeline" "service" {
name = local.resource_name
is_enabled = true
filter {
query = "source:${local.log_group_name}"
}
processor {
string_builder_processor {
target = "block"
template = local.block_name
name = "block name"
is_enabled = true
is_replace_missing = true
}
}
processor {
service_remapper {
sources = ["block"]
is_enabled = true
name = "remap service name"
}
}
processor {
// Extract container and task_id from log stream
grok_parser {
name = "extract container and task_id"
is_enabled = true
source = "aws.awslogs.logStream"
samples = [
"api/main/63de953809f14bb2a987eab110985d6e",
"api/datadog-agent/63de953809f14bb2a987eab110985d6e",
]
grok {
match_rules = "grok_parser %%{token}/%%{token:container}/%%{token:task_id}"
support_rules = <<EOF
token %%{regex("[^/]+")}
EOF
}
}
}
processor {
// Remap container to tag
attribute_remapper {
name = "remap container to tag"
is_enabled = true
source_type = "attribute"
sources = ["container"]
target_type = "tag"
target = "container"
preserve_source = true
override_on_conflict = false
}
}
processor {
// Remap task_id to tag
attribute_remapper {
name = "remap task_id to tag"
is_enabled = true
source_type = "attribute"
sources = ["task_id"]
target_type = "tag"
target = "task_id"
preserve_source = true
override_on_conflict = false
}
}
}