Add a prometheus exporter
Change-Id: I2989d87c2a83eed31c6617694bdcb78bf9b38553
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
index f34c0dc..11b2774 100644
--- a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/Constants.java
@@ -42,6 +42,10 @@
public static final String DEFAULT_INFLUXDB_MEASUREMENT = "sonaflow";
public static final boolean DEFAULT_INFLUXDB_ENABLE_BATCH = true;
+ // default configuration variables for Promethetus exporter
+ public static final String DEFAULT_PROMETHEUS_EXPORTER_IP = "0.0.0.0";
+ public static final int DEFAULT_PROMETHEUS_EXPORTER_PORT = 9501;
+
// default configuration variables for Kafka
public static final String DEFAULT_KAFKA_SERVER_IP = DEFAULT_SERVER_IP;
public static final int DEFAULT_KAFKA_SERVER_PORT = 9092;
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryAdminService.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryAdminService.java
new file mode 100644
index 0000000..15572c4
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryAdminService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacktelemetry.api;
+
+/**
+ * Admin service API for publishing openstack telemetry through Prometheus producer.
+ */
+public interface PrometheusTelemetryAdminService
+ extends TelemetryAdminService, PrometheusTelemetryService {
+}
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryConfigService.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryConfigService.java
new file mode 100644
index 0000000..4e115de
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryConfigService.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacktelemetry.api;
+
+/**
+ * Configuration service API for publishing openstack telemetry through Prometheus producer.
+ */
+public interface PrometheusTelemetryConfigService extends TelemetryConfigService {
+}
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryService.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryService.java
new file mode 100644
index 0000000..2680ab1
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/PrometheusTelemetryService.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacktelemetry.api;
+
+import java.util.Set;
+
+/**
+ * Service API for publishing openstack telemetry through Prometheus producer.
+ */
+public interface PrometheusTelemetryService extends TelemetryService {
+ /**
+ * Publishes openstack telemetry to Prometheus server.
+ *
+ * @param flowInfos a network metric to be published
+ */
+ void publish(Set<FlowInfo> flowInfos);
+}
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/config/PrometheusTelemetryConfig.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/config/PrometheusTelemetryConfig.java
new file mode 100644
index 0000000..536bd53
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/config/PrometheusTelemetryConfig.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacktelemetry.api.config;
+
+import java.util.Map;
+
+public interface PrometheusTelemetryConfig extends TelemetryConfig {
+
+ /**
+ * Obtains prometheus exporter IP address.
+ *
+ * @return IP address which prometheus exporter binds
+ */
+ String address();
+
+ /**
+ * Obtains prometheus exporter port number.
+ *
+ * @return prometheus exporter port number
+ */
+ int port();
+
+ /**
+ * Obtains prometheus config maps.
+ *
+ * @return prometheus config map
+ */
+ Map<String, Object> configMap();
+
+
+ /**
+ * Builder class of PrometheusTelemetryConfig.
+ */
+ interface Builder extends TelemetryConfig.Builder {
+
+ /**
+ * Sets prometheus exporter IP address.
+ *
+ * @param address prometheus exporter IP
+ * @return builder instance
+ */
+ Builder withAddress(String address);
+
+ /**
+ * Sets prometheus exporter port number.
+ *
+ * @param port prometheus exporter port
+ * @return builder instance
+ */
+ Builder withPort(int port);
+
+ // TODO add authentication.
+
+ /**
+ * Sets other prometheus configuration map.
+ *
+ * @param configMap prometheus configuration map
+ * @return builder instance
+ */
+ Builder withConfigMap(Map<String, Object> configMap);
+
+ /**
+ * Creates a prometheus telemetry config instance.
+ *
+ * @return prometheus telemetry config instance
+ */
+ PrometheusTelemetryConfig build();
+ }
+}