Configure xApp metrics in xApp description

Vesmgr subscribes the xApp notifications from xAppMgr. When it
receives a notification, it requests the xApp config from xAppMgr,
creates the VESPA configuration according to it, and restarts
VESPA with the new configuration.

The xApp counters should be defined in the xApp descriptor.
Vesmgr reads the counter definitions from section config->metrics.
The following fields are required:

* name - Prometheus name of the counter
* objectName - Ves collector object name
* objectInstance - Ves collector object instance

If the same counter name is defined by several xApps,
vesmgr makes the configuration based on the first definition
and ignores the latter ones, if they are conflicting.
However, VESPA reports all counters to Ves collector regardless
of the xApp exposing them.

VESPA reads the ricComponentName from Prometheus label
"kubernetes_name".

There are no more hard-coded metrics configured in this version.

Change-Id: I746c6941cebe686165aed97e223b0ec0e9c7a679
Signed-off-by: Katri Turunen <katri.turunen@nokia.com>
diff --git a/test/xApp_config_test_output.json b/test/xApp_config_test_output.json
new file mode 100644
index 0000000..fccda3f
--- /dev/null
+++ b/test/xApp_config_test_output.json
@@ -0,0 +1,292 @@
+[
+    {
+        "metadata": {
+            "name": "xApp1",
+            "configName": "xApp1-appconfig",
+            "namespace": "default"
+        },
+        "descriptor": {
+            "$id": "http://example.com/root.json",
+            "$schema": "http://json-schema.org/draft-07/schema#",
+            "definitions": {
+
+            },
+            "properties": {
+                "local": {
+                    "$id": "#/properties/local",
+                    "properties": {
+                        "host": {
+                            "$id": "#/properties/local/properties/host",
+                            "default": "",
+                            "examples": [
+                                ":8080"
+                            ],
+                            "pattern": "^(.*)$",
+                            "title": "The Host Schema",
+                            "type": "string"
+                        }
+                    },
+                    "required": [
+                        "host"
+                    ],
+                    "title": "The Local Schema",
+                    "type": "object"
+                },
+                "logger": {
+                    "$id": "#/properties/logger",
+                    "properties": {
+                        "level": {
+                            "$id": "#/properties/logger/properties/level",
+                            "default": 0,
+                            "examples": [
+                                3
+                            ],
+                            "title": "The Level Schema",
+                            "type": "integer"
+                        }
+                    },
+                    "required": [
+                        "level"
+                    ],
+                    "title": "The Logger Schema",
+                    "type": "object"
+                },
+                "metrics": {
+                    "$id": "#/properties/metrics",
+                    "items": {
+                        "$id": "#/properties/metrics/items",
+                        "properties": {
+                            "description": {
+                                "$id": "#/properties/metrics/items/properties/description",
+                                "default": "",
+                                "examples": [
+                                    "Example counter 1"
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Description Schema",
+                                "type": "string"
+                            },
+                            "enabled": {
+                                "$id": "#/properties/metrics/items/properties/enabled",
+                                "default": false,
+                                "examples": [
+                                    true
+                                ],
+                                "title": "The Enabled Schema",
+                                "type": "boolean"
+                            },
+                            "name": {
+                                "$id": "#/properties/metrics/items/properties/name",
+                                "default": "",
+                                "examples": [
+                                    "App1ExampleCounterOne"
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Name Schema",
+                                "type": "string"
+                            },
+                            "type": {
+                                "$id": "#/properties/metrics/items/properties/type",
+                                "default": "",
+                                "examples": [
+                                    "counter"
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Type Schema",
+                                "type": "string"
+                            }
+                        },
+                        "required": [
+                            "name",
+                            "type",
+                            "enabled",
+                            "description"
+                        ],
+                        "title": "The Items Schema",
+                        "type": "object"
+                    },
+                    "title": "The Metrics Schema",
+                    "type": "array"
+                }
+            },
+            "required": [
+                "local",
+                "logger",
+                "metrics"
+            ],
+            "title": "ANR Descriptor Schema",
+            "type": "object"
+        },
+        "config": {
+            "local": {
+                "host": ":8080"
+            },
+            "logger": {
+                "level": 5
+            },
+            "metrics": [
+                {
+                    "description": "Example counter 1",
+                    "enabled": true,
+                    "name": "App1ExampleCounterOne",
+                    "type": "counter",
+                    "objectName": "App1ExampleCounterOneObject",
+                    "objectInstance": "App1ExampleCounterOneObjectInstance"
+                },
+                {
+                    "description": "Example counter 2",
+                    "enabled": true,
+                    "name": "App1ExampleCounterTwo",
+                    "type": "counter",
+                    "objectName": "App1ExampleCounterTwoObject",
+                    "objectInstance": "App1ExampleCounterTwoObjectInstance"
+                }
+            ]
+        }
+    },
+    {
+        "metadata": {
+            "name": "xApp2",
+            "configName": "xApp2-appconfig",
+            "namespace": "default"
+        },
+        "descriptor": {
+            "$id": "http://example.com/root.json",
+            "$schema": "http://json-schema.org/draft-07/schema#",
+            "definitions": {
+
+            },
+            "properties": {
+                "local": {
+                    "$id": "#/properties/local",
+                    "properties": {
+                        "host": {
+                            "$id": "#/properties/local/properties/host",
+                            "default": "",
+                            "examples": [
+                                ":8080"
+                            ],
+                            "pattern": "^(.*)$",
+                            "title": "The Host Schema",
+                            "type": "string"
+                        }
+                    },
+                    "required": [
+                        "host"
+                    ],
+                    "title": "The Local Schema",
+                    "type": "object"
+                },
+                "logger": {
+                    "$id": "#/properties/logger",
+                    "properties": {
+                        "level": {
+                            "$id": "#/properties/logger/properties/level",
+                            "default": 0,
+                            "examples": [
+                                3
+                            ],
+                            "title": "The Level Schema",
+                            "type": "integer"
+                        }
+                    },
+                    "required": [
+                        "level"
+                    ],
+                    "title": "The Logger Schema",
+                    "type": "object"
+                },
+                "metrics": {
+                    "$id": "#/properties/metrics",
+                    "items": {
+                        "$id": "#/properties/metrics/items",
+                        "properties": {
+                            "description": {
+                                "$id": "#/properties/metrics/items/properties/description",
+                                "default": "",
+                                "examples": [
+                                    ""
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Description Schema",
+                                "type": "string"
+                            },
+                            "enabled": {
+                                "$id": "#/properties/metrics/items/properties/enabled",
+                                "default": false,
+                                "examples": [
+                                    true
+                                ],
+                                "title": "The Enabled Schema",
+                                "type": "boolean"
+                            },
+                            "name": {
+                                "$id": "#/properties/metrics/items/properties/name",
+                                "default": "",
+                                "examples": [
+                                    "UEContextCreated"
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Name Schema",
+                                "type": "string"
+                            },
+                            "type": {
+                                "$id": "#/properties/metrics/items/properties/type",
+                                "default": "",
+                                "examples": [
+                                    "counter"
+                                ],
+                                "pattern": "^(.*)$",
+                                "title": "The Type Schema",
+                                "type": "string"
+                            }
+                        },
+                        "required": [
+                            "name",
+                            "type",
+                            "enabled",
+                            "description"
+                        ],
+                        "title": "The Items Schema",
+                        "type": "object"
+                    },
+                    "title": "The Metrics Schema",
+                    "type": "array"
+                }
+            },
+            "required": [
+                "local",
+                "logger",
+                "metrics"
+            ],
+            "title": "The Root Schema",
+            "type": "object"
+        },
+        "config": {
+            "local": {
+                "host": ":8080"
+            },
+            "logger": {
+                "level": 3
+            },
+            "metrics": [
+                {
+                    "description": "Example counter",
+                    "enabled": true,
+                    "name": "App2ExampleCounterOne",
+                    "type": "counter",
+                    "objectName": "App2ExampleCounterOneObject",
+                    "objectInstance": "App2ExampleCounterOneObjectInstance"
+                },
+                {
+                    "description": "Another example counter",
+                    "enabled": true,
+                    "name": "App2ExampleCounterTwo",
+                    "type": "counter",
+                    "objectName": "App2ExampleCounterTwoObject",
+                    "objectInstance": "App2ExampleCounterTwoObjectInstance"
+                }
+            ]
+        }
+    }
+]