2 * Copyright (c) 2019 AT&T Intellectual Property.
3 * Copyright (c) 2018-2019 Nokia.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
28 func basicVespaConf() VESAgentConfiguration {
29 var vespaconf = VESAgentConfiguration {
32 Event: EventConfiguration {
33 VNFName: "vespa-demo", // XXX
34 ReportingEntityID: "1af5bfa9-40b4-4522-b045-40e54f0310f", // XXX
37 NfcNamingCodes: [] NfcNamingCode {
40 Vnfcs: [] string {"lr-ope-0","lr-ope-1","lr-ope-2"},
44 Vnfcs: [] string {"lr-pro-0","lr-pro-1"},
47 RetryInterval: time.Second * 5,
50 Measurement: MeasurementConfiguration {
51 DomainAbbreviation: "Mvfs",
52 MaxBufferingDuration: time.Hour,
53 Prometheus: PrometheusConfig {
54 Timeout: time.Second * 30,
55 KeepAlive: time.Second * 30,
57 DefaultValues: &MetricRule {
58 VMIDLabel: "'{{.labels.instance}}'",
67 func getRules(vespaconf *VESAgentConfiguration) {
69 makeRule := func(expr string, obj_name string, obj_instance string) MetricRule {
71 Target: "AdditionalObjects",
73 ObjectInstance: obj_instance,
75 ObjectKeys: [] Label {
77 Name: "ricComponentName",
78 Expr: "'{{.labels.app_kubernetes_io_instance}}'",
84 vespaconf.Measurement.Prometheus.Rules.Metrics = []MetricRule {
85 makeRule("ricxapp_RMR_Received", "ricxappRMRreceivedCounter", "ricxappRMRReceived"),
86 makeRule("ricxapp_RMR_ReceiveError", "ricxappRMRReceiveErrorCounter", "ricxappRMRReceiveError"),
87 makeRule("ricxapp_RMR_Transmitted", "ricxappRMRTransmittedCounter", "ricxappRMRTransmitted"),
88 makeRule("ricxapp_RMR_TransmitError", "ricxappRMRTransmitErrorCounter", "ricxappRMRTransmitError"),
89 makeRule("ricxapp_SDL_Stored", "ricxappSDLStoredCounter", "ricxappSDLStored"),
90 makeRule("ricxapp_SDL_StoreError", "ricxappSDLStoreErrorCounter", "ricxappSDLStoreError"),
95 func getCollectorConfiguration(vespaconf *VESAgentConfiguration) {
96 vespaconf.PrimaryCollector.User = os.Getenv("VESMGR_PRICOLLECTOR_USER")
97 vespaconf.PrimaryCollector.Password = os.Getenv("VESMGR_PRICOLLECTOR_PASSWORD")
98 vespaconf.PrimaryCollector.PassPhrase = os.Getenv("VESMGR_PRICOLLECTOR_PASSPHRASE")
99 vespaconf.PrimaryCollector.FQDN = os.Getenv("VESMGR_PRICOLLECTOR_ADDR")
100 vespaconf.PrimaryCollector.ServerRoot = os.Getenv("VESMGR_PRICOLLECTOR_SERVERROOT")
101 vespaconf.PrimaryCollector.Topic = os.Getenv("VESMGR_PRICOLLECTOR_TOPIC")
102 port_str := os.Getenv("VESMGR_PRICOLLECTOR_PORT")
104 vespaconf.PrimaryCollector.Port = 8443
106 port, _ := strconv.Atoi(port_str)
107 vespaconf.PrimaryCollector.Port = port
109 secure_str := os.Getenv("VESMGR_PRICOLLECTOR_SECURE")
110 if secure_str == "true" {
111 vespaconf.PrimaryCollector.Secure = true
113 vespaconf.PrimaryCollector.Secure = false
117 func createVespaConfig(writer io.Writer) {
118 vespaconf := basicVespaConf()
120 getCollectorConfiguration(&vespaconf)
121 err := yaml.NewEncoder(writer).Encode(vespaconf)
123 logger.Error("Cannot write vespa conf file: %s", err.Error())