From 530599c705f52ed4d7082833df0df77a609ef4db Mon Sep 17 00:00:00 2001 From: Johannes Grassler Date: Thu, 23 Nov 2017 10:04:25 +0100 Subject: [PATCH] Fix Kibana plugin config duplication This commit fixes the problem of the Kibana plugin's instances list getting appended to every time monasca-setup runs. See the referenced story for details. It also adds a cautionary note on avoiding the problem to plugin development documentation. Change-Id: I7c82028ad31798dcfe88e77c97c41da87c9743fa Story: 2001311 Task: 5865 --- docs/Customizations.md | 8 +++++++- monasca_setup/detection/plugins/kibana.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/Customizations.md b/docs/Customizations.md index b8717205..02c16378 100644 --- a/docs/Customizations.md +++ b/docs/Customizations.md @@ -205,7 +205,13 @@ In the init_config section you can specify an arbitrary number of global name:va ##### instances The instances section is a list of instances that this check will be run against. Your actual check() method is run once per instance. The name:value pairs for each instance specify details about the instance that are necessary for the check. -It is best practice to include a name for each instance as the monasca-setup program uses this to avoid duplicating instances. +It is vitally important to have a `name` attribute with a unique value for each +instance as the `monasca-setup` program uses this to avoid duplicating +instances. If any of the instances does not have a `name` attribute, +`monasca-setup` will duplicate it every time it runs, causing not only a +cluttered configuration file but also a multiplication of metrics sent by the +plugin. See https://storyboard.openstack.org/#!/story/2001311 for an example of +the plugin where this problem occurred. #### DynamicCheckHelper class diff --git a/monasca_setup/detection/plugins/kibana.py b/monasca_setup/detection/plugins/kibana.py index b668679a..f72c9458 100644 --- a/monasca_setup/detection/plugins/kibana.py +++ b/monasca_setup/detection/plugins/kibana.py @@ -132,6 +132,7 @@ class Kibana(detection.Plugin): }, 'instances': [ { + "name": kibana_url, 'metrics': metrics } ]