Add telegraf, prometheus and grafana offer

Signed-off-by: Arif Ali <arif.ali@canonical.com>
This commit is contained in:
Arif Ali 2024-06-14 19:47:07 +01:00
parent d90e3641f7
commit 6ca800abf4
Signed by: arif
GPG Key ID: 369608FBA1353A70
3 changed files with 175 additions and 1 deletions

View File

@ -0,0 +1,110 @@
resource "juju_application" "telegraf" {
name = "telegraf"
model = var.model-name
charm {
name = "telegraf"
channel = "latest/stable"
}
units = 0
endpoint_bindings = [{
space = var.oam-space
},{
endpoint = "prometheus-client"
space = var.oam-space
}]
config = {
socket_listener_port = "8095"
install_sources = <<-EOF
- 'deb http://192.168.1.12/ppa.launchpad.net/telegraf-devs/ppa/ubuntu focal main'
EOF
install_keys = <<-EOF
- |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
Comment: Hostname: keyserver.ubuntu.com
mQINBFcVSuIBEAC80aj0tAQ6+NhGV/bkSwu6Oj+BpDR50Be3uBv7ttdtvChL5zHTnaxjdK3h
LKSyrDLlmSOkffQ2uO7CxvqeF09MsHhyvrDDx0EY54//xxoAB++PoB2OQqmqldg3Al5Hp4Dz
rllV5CIX5PD8NGX8UpO3HXk5wEwn9G81l8cia3vPveU82EIkHMiJGpk6+L86OMlwXzxkSI3M
xXgNFKQc+ELDYLvGSseYC9vPN3kdmFoo/UjznPPE4fxr4bXit3N8Abl1jYjBa0x6SWkK1BAb
s8w3BXtvyk90z9Oyme69wPD4zAYfFp+kN2nDmTDBMtNCyMu9oatdI5SukMNK4Lcm8eAE6VNs
04j7BKvGk9+17M8WP9Pw8nIisOwScS9gUlJlLUpnBaJ+sxoOvGQ4mzZxYMKzJh0E58aEX3bS
AyzQfsae8bZLNOTcgotyzzIDJFF9npzu3wmKjeOt/706p4LiDqKUbQK6cI+QcJ/y80ZUK8pB
M043ttSHWLmTBFX2drp6zQGae9+02fX89ZD+5c+MPlubJMYCCKkvQT4OssHfC+dVDQ66rwUy
OObrzsVgikdpIxQVitL3J+Dms56xAkdFfoo+qdxxdv9S/eakc5mfavc/4WVvmFDaJiqJnJRR
Ryw1zApRtuweEEdVn8niy1mahoKpWaw1pTI4AazjWI6xJH1JyQARAQABtB9MYXVuY2hwYWQg
UFBBIGZvciBUZWxlZ3JhZiBEZXZziQI4BBMBAgAiBQJXFUriAhsDBgsJCAcDAgYVCAIJCgsE
FgIDAQIeAQIXgAAKCRDxDL4ByUQG9UgbEACa4IzdeYxH/S5I6MrZfvWNo/JTZ/MZWDD+QlMW
60ThAemCUSE+NJvZZ1q7ovGFpYnHJT9GQXOwJAX1quDUqyM1uXNmLlOyIVNnmjUTINoLhw2V
iC8E7dMWC9w4Na2fKezmNHH00kNl43ncstIjjZ3pLnDGYm1y0ItiCUcTRgHhx2cUZ/vStz1S
Pdqj4P3i8vuspoYJ2T3VPlM/0G+u9Yjuy3Uzu9RugOyO3UJPoi3+4O2VTNosSBy5MILVCp49
eigyFVGpq5sT/c86qd1zqmsNWEubrlzDfETS4LMj9epr46ZKPXGQkeryt1m2Oe0HkIdNZ+IQ
5p+i9fnEy7/1uKTXWQYsg2UWsLA2PvTvwY8JxxMhUFgv12q2w7STntqJyi9PLItYNtbtKoS3
XZCCMqQLCWMXHY+2ol6rRSfs06H/wzlR8LjDaEXkDVuDmqMtcbgTboZYblsGxst7I/Y4Wgfi
J52uiIyobQ69uJbG0XeRTLZ3WyrBkopEsTX/+sQjVqbADXYU4hBVDgnCf2uN/5dcwSEvDj8/
+WsToAfEJkscRBsQjTLVzf+eFqHLrbqz/yoYIqBc//IJMBSbxIf5mrOHHLdbOuMCB6PVwpTI
vLFOSDNPuVDX+S1goA8KJTnXpm8jWDynn3XaXx3AlYw4iZ0ETSgQLQLRd6JuPOEGXsGdBA==
=ufaX
-----END PGP PUBLIC KEY BLOCK-----
EOF
extra_plugins = <<-EOF
[[inputs.exec]]
commands = [ "/usr/bin/awk '{print int($1)}' /proc/uptime" ]
name_override = "exec_uptime"
data_format = "value"
EOF
}
}
locals {
physical_apps = ["ceph-osd", "neutron-gateway"]
}
resource "juju_integration" "telegraf-integration" {
for_each = toset(local.physical_apps)
model = var.model-name
application {
name = juju_application.telegraf.name
endpoint = "juju-info"
}
application {
name = "${each.value}"
endpoint = "juju-info"
}
}
resource "juju_integration" "telegraf-grafana" {
model = var.model-name
application {
name = juju_application.telegraf.name
endpoint = "dashboards"
}
application {
offer_url = juju_offer.grafana.url
}
}
resource "juju_integration" "telegraf-prometheus" {
model = var.model-name
application {
name = juju_application.telegraf.name
endpoint = "prometheus-client"
}
application {
offer_url = juju_offer.prometheus.url
}
}

View File

@ -29,4 +29,8 @@ resource "juju_application" "grafana" {
}
}
#- [ "graylog:mongodb", "graylog-mongodb:database" ]
resource "juju_offer" "grafana" {
model = var.lma-model-name
application_name = juju_application.grafana.name
endpoint = "dashboards"
}

View File

@ -0,0 +1,60 @@
resource "juju_machine" "prometheus" {
model = var.lma-model-name
placement = join(":", ["lxd", juju_machine.lma_machines["201"].machine_id])
constraints = "spaces=oam"
}
resource "juju_application" "prometheus" {
name = "prometheus"
model = var.lma-model-name
charm {
name = "prometheus2"
channel = "latest/stable"
base = "ubuntu@20.04"
}
units = 1
placement = juju_machine.prometheus.machine_id
endpoint_bindings = [{
space = var.oam-space
}]
}
resource "juju_integration" "prometheus-grafana" {
model = var.lma-model-name
application {
name = juju_application.prometheus.name
endpoint = "grafana-source"
}
application {
name = juju_application.grafana.name
endpoint = "grafana-source"
}
}
resource "juju_integration" "ceph-mon-prometheus" {
model = var.model-name
application {
name = juju_application.ceph-mon.name
endpoint = "prometheus"
}
application {
offer_url = juju_offer.prometheus.url
}
}
resource "juju_offer" "prometheus" {
model = var.lma-model-name
application_name = juju_application.prometheus.name
endpoint = "target"
}