-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Percona's MongoDB exporter to observe database related metrics
- Loading branch information
1 parent
bea2aea
commit 3eec0e1
Showing
10 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.21.1 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.21.1 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [kubernetes_deployment.mongodb_exporter](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment) | resource | | ||
| [kubernetes_service.mongodb_exporter_service](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_certif_mount"></a> [certif\_mount](#input\_certif\_mount) | MongoDB certificate mount secret | <pre>map(object({<br> secret = string<br> path = string<br> mode = string<br> }))</pre> | n/a | yes | | ||
| <a name="input_docker_image"></a> [docker\_image](#input\_docker\_image) | Docker image for partition metrics exporter | <pre>object({<br> image = string<br> tag = string<br> image_pull_secrets = string<br> })</pre> | n/a | yes | | ||
| <a name="input_mongo_url"></a> [mongo\_url](#input\_mongo\_url) | Full MongoDB URI with credentials and tls options included | `string` | n/a | yes | | ||
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of ArmoniK resources | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_namespace"></a> [namespace](#output\_namespace) | Namespace of the MongoDB metrics exporter | | ||
| <a name="output_url"></a> [url](#output\_url) | Url of the MongoDB Metrics exporter | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
resource "kubernetes_deployment" "mongodb_exporter" { | ||
metadata { | ||
name = "mongodb-metrics-exporter" | ||
namespace = var.namespace | ||
labels = { | ||
app = "armonik" | ||
type = "monitoring" | ||
service = "mongodb-metrics-exporter" | ||
} | ||
} | ||
|
||
spec { | ||
replicas = 1 | ||
selector { | ||
match_labels = { | ||
app = "armonik" | ||
type = "monitoring" | ||
service = "mongodb-metrics-exporter" | ||
} | ||
} | ||
|
||
template { | ||
metadata { | ||
name = "mongodb-metrics-exporter" | ||
namespace = var.namespace | ||
labels = { | ||
app = "armonik" | ||
type = "monitoring" | ||
service = "mongodb-metrics-exporter" | ||
} | ||
} | ||
spec { | ||
container { | ||
name = "mongodb-metrics-exporter" | ||
image = var.docker_image.tag != "" ? "${var.docker_image.image}:${var.docker_image.tag}" : var.docker_image.image | ||
|
||
env { | ||
name = "MONGODB_URI" | ||
value = var.mongo_url | ||
} | ||
|
||
dynamic "volume_mount" { | ||
for_each = var.certif_mount | ||
content { | ||
mount_path = volume_mount.value.path | ||
name = volume_mount.value.secret | ||
read_only = true | ||
} | ||
} | ||
|
||
args = ["--log.level=error", "--collector.diagnosticdata", "--collector.replicasetstatus", "--collector.dbstats", "--collector.dbstatsfreestorage", "--collector.topmetrics", "--collector.currentopmetrics", "--collector.indexstats", "--collector.collstats", "--discovering-mode", "--mongodb.uri=$(MONGODB_URI)"] | ||
} | ||
|
||
dynamic "volume" { | ||
for_each = var.certif_mount | ||
content { | ||
name = volume.value.secret | ||
secret { | ||
secret_name = volume.value.secret | ||
default_mode = volume.value.mode | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
resource "kubernetes_service" "mongodb_exporter_service" { | ||
metadata { | ||
name = "mongodb-metrics-exporter" | ||
namespace = var.namespace | ||
labels = { | ||
app = "armonik" | ||
type = "monitoring" | ||
service = "mongodb-metrics-exporter" | ||
} | ||
} | ||
|
||
spec { | ||
selector = { | ||
app = "armonik" | ||
type = "monitoring" | ||
service = "mongodb-metrics-exporter" | ||
} | ||
|
||
port { | ||
port = 9216 | ||
target_port = 9216 | ||
protocol = "TCP" | ||
} | ||
|
||
type = "ClusterIP" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
monitoring/onpremise/exporters/mongodb-exporter/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# MongoDB metrics exporter | ||
|
||
output "url" { | ||
description = "Url of the MongoDB Metrics exporter" | ||
value = "${kubernetes_service.mongodb_exporter_service.spec[0].cluster_ip}:${kubernetes_service.mongodb_exporter_service.spec[0].port[0].port}" | ||
} | ||
|
||
output "namespace" { | ||
description = "Namespace of the MongoDB metrics exporter" | ||
value = var.namespace | ||
} |
29 changes: 29 additions & 0 deletions
29
monitoring/onpremise/exporters/mongodb-exporter/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Global variables | ||
variable "namespace" { | ||
description = "Namespace of ArmoniK resources" | ||
type = string | ||
} | ||
|
||
# Docker image | ||
variable "docker_image" { | ||
description = "Docker image for partition metrics exporter" | ||
type = object({ | ||
image = string | ||
tag = string | ||
image_pull_secrets = string | ||
}) | ||
} | ||
|
||
variable "certif_mount" { | ||
description = "MongoDB certificate mount secret" | ||
type = map(object({ | ||
secret = string | ||
path = string | ||
mode = string | ||
})) | ||
} | ||
|
||
variable "mongo_url" { | ||
description = "Full MongoDB URI with credentials and tls options included" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = ">= 2.21.1" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use admin; | ||
db.createUser({ | ||
user: "mongodb_exporter", | ||
pwd: "mongodb_exporter", | ||
roles: [ | ||
{ role: "clusterMonitor", db: "admin"}, | ||
{ role: "read", db: "local"} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters