Skip to content

Commit 320336f

Browse files
authored
feat: added support for logdna agent tags (#15)
1 parent 8feaf69 commit 320336f

File tree

10 files changed

+48
-8
lines changed

10 files changed

+48
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ Brewfile.lock.json
5454

5555
# Visual Studio Code
5656
.vscode/
57+
*.code-workspace

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ No modules.
124124
|------|-------------|------|---------|:--------:|
125125
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Cluster id to add to agents to | `string` | n/a | yes |
126126
| <a name="input_cluster_resource_group_id"></a> [cluster\_resource\_group\_id](#input\_cluster\_resource\_group\_id) | Resource group of the cluster | `string` | n/a | yes |
127+
| <a name="input_logdna_agent_tags"></a> [logdna\_agent\_tags](#input\_logdna\_agent\_tags) | array of tags to group the host logs pushed by the logdna agent | `list(string)` | `[]` | no |
127128
| <a name="input_logdna_agent_version"></a> [logdna\_agent\_version](#input\_logdna\_agent\_version) | Version of the agent to deploy. To lookup version run: `ibmcloud cr images --restrict ext/logdna-agent`. If null, the default value is used. | `string` | `"3.8.0-20230206.cbc937fa5513f636"` | no |
128129
| <a name="input_logdna_enabled"></a> [logdna\_enabled](#input\_logdna\_enabled) | Deploy IBM Cloud Logging agent | `bool` | `true` | no |
129130
| <a name="input_logdna_ingestion_key"></a> [logdna\_ingestion\_key](#input\_logdna\_ingestion\_key) | Ingestion key for the IBM Cloud Logging agent to communicate with the instance | `string` | `null` | no |

chart/logdna-agent/templates/daemonset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
{{- end }}
5454
- name: LOGDNA_LOOKBACK
5555
value: smallfiles
56+
{{- if .Values.agent.tags }}
57+
- name: LOGDNA_TAGS
58+
value: {{.Values.agent.tags}}
59+
{{- end }}
5660
- name: LOGDNA_DB_PATH
5761
value: /var/lib/logdna
5862
- name: LOGDNA_REDACT_REGEX

chart/logdna-agent/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ tolerations:
1717
- key: "dedicated"
1818
value: "transit"
1919
effect: "NoExecute"
20+
agent:
21+
tags: ""

examples/basic/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ module "observability_agents" {
104104
logdna_ingestion_key = module.observability_instances.logdna_ingestion_key
105105
sysdig_instance_name = module.observability_instances.sysdig_name
106106
sysdig_access_key = module.observability_instances.sysdig_access_key
107-
107+
logdna_agent_tags = var.logdna_agent_tags
108108
}

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ variable "region" {
2727
description = "Region where resources are created"
2828
default = "ca-tor"
2929
}
30+
31+
variable "logdna_agent_tags" {
32+
type = list(string)
33+
description = "Array of string of tags for logdna agent"
34+
default = []
35+
}

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ resource "helm_release" "logdna_agent" {
100100
type = "string"
101101
value = var.logdna_ingestion_key
102102
}
103+
set {
104+
name = "agent.tags"
105+
type = "string"
106+
value = join("\\,", var.logdna_agent_tags)
107+
}
103108

104109
provisioner "local-exec" {
105110
command = "${path.module}/scripts/confirm-rollout-status.sh logdna-agent ${local.logdna_agent_namespace}"

module-metadata.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
"cloud_data_type": "resource_group",
3636
"computed": true
3737
},
38+
"logdna_agent_tags": {
39+
"name": "logdna_agent_tags",
40+
"type": "list(string)",
41+
"description": "array of tags to group the host logs pushed by the logdna agent",
42+
"default": [],
43+
"pos": {
44+
"filename": "variables.tf",
45+
"line": 42
46+
}
47+
},
3848
"logdna_agent_version": {
3949
"name": "logdna_agent_version",
4050
"type": "string",
@@ -69,7 +79,7 @@
6979
],
7080
"pos": {
7181
"filename": "variables.tf",
72-
"line": 43
82+
"line": 48
7383
}
7484
},
7585
"logdna_instance_name": {
@@ -104,7 +114,7 @@
104114
],
105115
"pos": {
106116
"filename": "variables.tf",
107-
"line": 76
117+
"line": 81
108118
}
109119
},
110120
"sysdig_agent_version": {
@@ -114,7 +124,7 @@
114124
"default": "12.10.1",
115125
"pos": {
116126
"filename": "variables.tf",
117-
"line": 68
127+
"line": 73
118128
}
119129
},
120130
"sysdig_enabled": {
@@ -128,7 +138,7 @@
128138
],
129139
"pos": {
130140
"filename": "variables.tf",
131-
"line": 50
141+
"line": 55
132142
}
133143
},
134144
"sysdig_instance_name": {
@@ -141,7 +151,7 @@
141151
],
142152
"pos": {
143153
"filename": "variables.tf",
144-
"line": 56
154+
"line": 61
145155
}
146156
},
147157
"sysdig_resource_group_id": {
@@ -150,7 +160,7 @@
150160
"description": "Resource group that the IBM Cloud Monitoring is in. Defaults to Clusters group",
151161
"pos": {
152162
"filename": "variables.tf",
153-
"line": 62
163+
"line": 67
154164
}
155165
}
156166
},
@@ -200,7 +210,7 @@
200210
},
201211
"pos": {
202212
"filename": "main.tf",
203-
"line": 116
213+
"line": 121
204214
}
205215
}
206216
},

tests/pr_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.
4848
func TestRunBasicAgents(t *testing.T) {
4949
t.Parallel()
5050

51+
logDNATagsList := []string{"tag1", "tag2"}
52+
5153
options := setupOptions(t, "basic-obs-agents", terraformDirOther)
5254

55+
options.TerraformVars = map[string]interface{}{
56+
"logdna_agent_tags": logDNATagsList,
57+
}
58+
5359
output, err := options.RunTestConsistency()
5460
assert.Nil(t, err, "This should not have errored")
5561
assert.NotNil(t, output, "Expected some output")

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ variable "logdna_agent_version" {
3939
nullable = false
4040
}
4141

42+
variable "logdna_agent_tags" {
43+
type = list(string)
44+
description = "array of tags to group the host logs pushed by the logdna agent"
45+
default = []
46+
}
4247

4348
variable "logdna_ingestion_key" {
4449
type = string

0 commit comments

Comments
 (0)