Skip to content

Commit 2e00d1c

Browse files
feat: added new input variables sysdig_agent_tags and sysdig_add_cluster_name (#217)
1 parent cf42956 commit 2e00d1c

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ No modules.
131131
| <a name="input_logdna_instance_name"></a> [logdna\_instance\_name](#input\_logdna\_instance\_name) | IBM Cloud Logging instance to use. Required if LogDNA is enabled | `string` | `null` | no |
132132
| <a name="input_logdna_resource_group_id"></a> [logdna\_resource\_group\_id](#input\_logdna\_resource\_group\_id) | Resource group the IBM Cloud Logging instance is in. Defaults to Clusters group | `string` | `null` | no |
133133
| <a name="input_sysdig_access_key"></a> [sysdig\_access\_key](#input\_sysdig\_access\_key) | Access key used by the IBM Cloud Monitoring agent to communicate with the instance | `string` | `null` | no |
134+
| <a name="input_sysdig_add_cluster_name"></a> [sysdig\_add\_cluster\_name](#input\_sysdig\_add\_cluster\_name) | If true, configure the sysdig agent to attach a tag containing the cluster name to all metric data. | `bool` | `true` | no |
135+
| <a name="input_sysdig_agent_tags"></a> [sysdig\_agent\_tags](#input\_sysdig\_agent\_tags) | array of tags to group the host metrics pushed by the sysdig agent | `list(string)` | `[]` | no |
134136
| <a name="input_sysdig_agent_version"></a> [sysdig\_agent\_version](#input\_sysdig\_agent\_version) | IBM Cloud Monitoring Agent Version. To lookup version run: `ibmcloud cr images --restrict ext/sysdig/agent`. If null, the default value is used. | `string` | `"12.17.1"` | no |
135137
| <a name="input_sysdig_enabled"></a> [sysdig\_enabled](#input\_sysdig\_enabled) | Deploy IBM Cloud Monitoring agent | `bool` | `true` | no |
136138
| <a name="input_sysdig_instance_name"></a> [sysdig\_instance\_name](#input\_sysdig\_instance\_name) | The name of the IBM Cloud Monitoring instance to use. Required if Sysdig is enabled | `string` | `null` | no |

examples/basic/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ module "observability_agents" {
110110
logdna_ingestion_key = module.observability_instances.log_analysis_ingestion_key
111111
sysdig_instance_name = module.observability_instances.cloud_monitoring_name
112112
sysdig_access_key = module.observability_instances.cloud_monitoring_access_key
113-
logdna_agent_tags = var.logdna_agent_tags
113+
logdna_agent_tags = var.resource_tags
114114
logdna_add_cluster_name = true
115115
# example of how to include / exclude metrics - more info https://cloud.ibm.com/docs/monitoring?topic=monitoring-change_kube_agent#change_kube_agent_log_metrics
116116
sysdig_metrics_filter = [{ type = "exclude", name = "metricA.*" }, { type = "include", name = "metricB.*" }]
117+
sysdig_agent_tags = var.resource_tags
117118
}

examples/basic/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ locals {
6161
sysdig_key_validate_msg = "Values for 'sysdig_access_key' variables must be passed when 'sysdig_enabled = true'"
6262
# tflint-ignore: terraform_unused_declarations
6363
sysdig_key_validate_check = regex("^${local.sysdig_key_validate_msg}$", (!local.sysdig_key_validate_condition ? local.sysdig_key_validate_msg : ""))
64+
sysdig_agent_tags = var.sysdig_add_cluster_name ? concat([local.cluster_name], var.sysdig_agent_tags) : var.sysdig_agent_tags
6465
}
6566

6667
/** LogDNA Configuration Start **/
@@ -158,6 +159,12 @@ resource "helm_release" "sysdig_agent" {
158159
value = var.sysdig_access_key
159160
}
160161

162+
set {
163+
name = "agent.tags"
164+
type = "string"
165+
value = join("\\,", local.sysdig_agent_tags)
166+
}
167+
161168
values = [yamlencode({
162169
metrics_filter = var.sysdig_metrics_filter
163170
})]

tests/pr_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ var ignoreUpdates = []string{
2121

2222
var sharedInfoSvc *cloudinfo.CloudInfoService
2323

24-
var logDNATagsList = []string{"tag1", "tag2"}
25-
2624
// TestMain will be run before any parallel tests, used to set up a shared InfoService object to track region usage
2725
// for multiple tests
2826
func TestMain(m *testing.M) {
@@ -37,9 +35,6 @@ func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.
3735
TerraformDir: terraformDir,
3836
Prefix: prefix,
3937
ResourceGroup: resourceGroup,
40-
TerraformVars: map[string]interface{}{
41-
"logdna_agent_tags": logDNATagsList,
42-
},
4338
IgnoreUpdates: testhelper.Exemptions{
4439
List: ignoreUpdates,
4540
},

variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,17 @@ variable "sysdig_metrics_filter" {
105105
}
106106
}
107107

108+
variable "sysdig_agent_tags" {
109+
type = list(string)
110+
description = "array of tags to group the host metrics pushed by the sysdig agent"
111+
default = []
112+
nullable = false
113+
}
114+
115+
variable "sysdig_add_cluster_name" {
116+
type = bool
117+
description = "If true, configure the sysdig agent to attach a tag containing the cluster name to all metric data."
118+
default = true
119+
}
120+
108121
##############################################################################

0 commit comments

Comments
 (0)