Skip to content

Commit 602ae79

Browse files
committed
addressed review comments
1 parent 85bd171 commit 602ae79

File tree

9 files changed

+49
-79
lines changed

9 files changed

+49
-79
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ No modules.
146146
| <a name="input_metrics_filter"></a> [metrics\_filter](#input\_metrics\_filter) | To filter custom metrics you can specify which metrics to include and exclude. For more info, see https://cloud.ibm.com/docs/monitoring?topic=monitoring-change_kube_agent#change_kube_agent_inc_exc_metrics | <pre>list(object({<br/> include = optional(string)<br/> exclude = optional(string)<br/> }))</pre> | `[]` | no |
147147
| <a name="input_name"></a> [name](#input\_name) | The name to give the agent helm release. | `string` | `"sysdig-agent"` | no |
148148
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to deploy the agent to. | `string` | `"ibm-observe"` | no |
149-
| <a name="input_prometheus"></a> [prometheus](#input\_prometheus) | Prometheus configuration for the agent. If you want to enable Prometheus configuration, set `file` to true and provide the prometheus.yaml file content in `yaml`. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus). | <pre>object({<br/> file = bool<br/> yaml = map(any)<br/> })</pre> | <pre>{<br/> "file": false,<br/> "yaml": {}<br/>}</pre> | no |
149+
| <a name="input_prometheus_config"></a> [prometheus\_config](#input\_prometheus\_config) | Prometheus configuration for the agent. If you want to enable Prometheus configuration provide the prometheus.yaml file content in `hcl` format. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus). | `map(any)` | `{}` | no |
150150
| <a name="input_tolerations"></a> [tolerations](#input\_tolerations) | List of tolerations to apply to the agent. | <pre>list(object({<br/> key = optional(string)<br/> operator = optional(string)<br/> value = optional(string)<br/> effect = optional(string)<br/> tolerationSeconds = optional(number)<br/> }))</pre> | <pre>[<br/> {<br/> "operator": "Exists"<br/> },<br/> {<br/> "effect": "NoSchedule",<br/> "key": "node-role.kubernetes.io/master",<br/> "operator": "Exists"<br/> }<br/>]</pre> | no |
151151
| <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Whether send data over a private endpoint or not. To use a private endpoint, you must enable virtual routing and forwarding (VRF) for your account. See https://cloud.ibm.com/docs/account?topic=account-vrf-service-endpoint. | `bool` | `true` | no |
152152
| <a name="input_use_scc_wp_endpoint"></a> [use\_scc\_wp\_endpoint](#input\_use\_scc\_wp\_endpoint) | By default an IBM Cloud Monitoring endpoint is used and is constructed from the `instance_region` and `use_private_endpoint` inputs. To use an IBM Cloud Security and Compliance Center Workload Protection endpoint instead, set this to true. | `bool` | `false` | no |

examples/obs-agent-iks/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,5 @@ module "monitoring_agents" {
145145
is_vpc_cluster = var.is_vpc_cluster
146146
access_key = module.cloud_monitoring.access_key
147147
instance_region = var.region
148+
prometheus_config = var.prometheus_config
148149
}

examples/obs-agent-iks/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ variable "datacenter" {
3939
description = "If creating a classic cluster, the data center where the cluster is created"
4040
default = "syd01"
4141
}
42+
43+
variable "prometheus_config" {
44+
description = "Prometheus configuration for the agent. If you want to enable Prometheus configuration provide the prometheus.yaml file content in `hcl` format. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus)."
45+
type = map(any)
46+
default = {}
47+
}

ibm_catalog.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@
302302
"original_grouping": "deployment"
303303
}
304304
},
305-
{
306-
"key": "prometheus"
307-
},
308305
{
309306
"key": "cluster_config_endpoint_type",
310307
"options": [

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ resource "helm_release" "cloud_monitoring_agent" {
254254
"name": "tmp-vol"
255255
%{endif~}
256256
"prometheus":
257-
"file": ${var.prometheus.file}
257+
"file": ${length(var.prometheus_config) > 0}
258258
"yaml":
259-
%{for line in split("\n", yamlencode(var.prometheus.yaml))~}
259+
%{for line in split("\n", yamlencode(var.prometheus_config))~}
260260
${line}
261261
%{endfor~}
262262
EOT

solutions/fully-configurable/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ module "monitoring_agent" {
2828
blacklisted_ports = var.blacklisted_ports
2929
metrics_filter = var.metrics_filter
3030
container_filter = var.container_filter
31-
prometheus = var.prometheus
3231
tolerations = var.tolerations
3332
chart = var.chart
3433
chart_location = var.chart_location

solutions/fully-configurable/variables.tf

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,24 +278,6 @@ variable "container_filter" {
278278
}
279279
}
280280

281-
variable "prometheus" {
282-
description = "Prometheus configuration for the agent. If you want to enable Prometheus configuration, set `file` to true and provide the prometheus.yaml file content in `yaml`. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus)."
283-
type = object({
284-
file = bool
285-
yaml = map(any)
286-
})
287-
default = {
288-
file = false
289-
yaml = {}
290-
}
291-
validation {
292-
condition = (
293-
var.prometheus.file == false || length(keys(var.prometheus.yaml)) > 0
294-
)
295-
error_message = "If prometheus.file is true, 'yaml' must be a non-empty map."
296-
}
297-
}
298-
299281
##############################################################################
300282
# SCC-WP related variables
301283
##############################################################################

tests/pr_test.go

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -112,50 +112,12 @@ func TestFullyConfigurableSolution(t *testing.T) {
112112
WaitJobCompleteMinutes: 60,
113113
Region: region,
114114
})
115-
116-
prometheus := map[string]interface{}{
117-
"file": true,
118-
"yaml": map[string]interface{}{
119-
120-
"scrape_configs": []map[string]interface{}{
121-
{
122-
"job_name": "testing-prometheus-scrape",
123-
"tls_config": map[string]interface{}{
124-
"insecure_skip_verify": true,
125-
},
126-
"kubernetes_sd_configs": []map[string]interface{}{
127-
{
128-
"role": "pod",
129-
},
130-
},
131-
"relabel_configs": []map[string]interface{}{
132-
{
133-
"action": "keep",
134-
"source_labels": []string{"__meta_kubernetes_pod_host_ip"},
135-
"regex": "__HOSTIPS__",
136-
},
137-
{
138-
"action": "drop",
139-
"source_labels": []string{"__meta_kubernetes_pod_annotation_promcat_sysdig_com_omit"},
140-
"regex": true,
141-
},
142-
{
143-
"action": "keep",
144-
"source_labels": []string{"__meta_kubernetes_pod_phase"},
145-
"regex": "Running",
146-
},
147-
},
148-
},
149-
},
150-
},
151-
}
152115
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
153116
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
154117
{Name: "instance_region", Value: region, DataType: "string"},
155118
{Name: "cluster_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_id"), DataType: "string"},
156119
{Name: "cluster_resource_group_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_resource_group_id"), DataType: "string"},
157120
{Name: "access_key", Value: terraform.Output(t, existingTerraformOptions, "access_key"), DataType: "string", Secure: true},
158-
{Name: "prometheus", Value: prometheus, DataType: "object{}", Secure: true},
159121
}
160122

161123
err := options.RunSchematicTest()
@@ -277,6 +239,41 @@ func TestRunAgentVpcKubernetes(t *testing.T) {
277239
CloudInfoService: sharedInfoSvc,
278240
})
279241

242+
prometheus_config := map[string]interface{}{
243+
244+
"scrape_configs": []map[string]interface{}{
245+
{
246+
"job_name": "testing-prometheus-scrape",
247+
"tls_config": map[string]interface{}{
248+
"insecure_skip_verify": true,
249+
},
250+
"kubernetes_sd_configs": []map[string]interface{}{
251+
{
252+
"role": "pod",
253+
},
254+
},
255+
"relabel_configs": []map[string]interface{}{
256+
{
257+
"action": "keep",
258+
"source_labels": []string{"__meta_kubernetes_pod_host_ip"},
259+
"regex": "__HOSTIPS__",
260+
},
261+
{
262+
"action": "drop",
263+
"source_labels": []string{"__meta_kubernetes_pod_annotation_promcat_sysdig_com_omit"},
264+
"regex": true,
265+
},
266+
{
267+
"action": "keep",
268+
"source_labels": []string{"__meta_kubernetes_pod_phase"},
269+
"regex": "Running",
270+
},
271+
},
272+
},
273+
},
274+
}
275+
276+
options.TerraformVars["prometheus_config"] = prometheus_config
280277
output, err := options.RunTestConsistency()
281278
assert.Nil(t, err, "This should not have errored")
282279
assert.NotNil(t, output, "Expected some output")

variables.tf

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,10 @@ variable "container_filter" {
280280
}
281281
}
282282

283-
variable "prometheus" {
284-
description = "Prometheus configuration for the agent. If you want to enable Prometheus configuration, set `file` to true and provide the prometheus.yaml file content in `yaml`. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus)."
285-
type = object({
286-
file = bool
287-
yaml = map(any)
288-
})
289-
default = {
290-
file = false
291-
yaml = {}
292-
}
293-
validation {
294-
condition = (
295-
var.prometheus.file == false || length(keys(var.prometheus.yaml)) > 0
296-
)
297-
error_message = "If prometheus.file is true, 'yaml' must be a non-empty map."
298-
}
283+
variable "prometheus_config" {
284+
description = "Prometheus configuration for the agent. If you want to enable Prometheus configuration provide the prometheus.yaml file content in `hcl` format. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus)."
285+
type = map(any)
286+
default = {}
299287
}
300288

301289
##############################################################################

0 commit comments

Comments
 (0)