diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/.classpath b/prometheus-integration/com.tibco.bw.prometheus.monitor/.classpath
index 34ad905..fd1a29b 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/.classpath
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/.classpath
@@ -1,15 +1,18 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/META-INF/MANIFEST.MF b/prometheus-integration/com.tibco.bw.prometheus.monitor/META-INF/MANIFEST.MF
index d4143c5..9043538 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/META-INF/MANIFEST.MF
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/META-INF/MANIFEST.MF
@@ -1,56 +1,56 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Prometheus Monitoring for BW application
-Bundle-SymbolicName: com.tibco.bw.prometheus.monitor
-Bundle-Version: 1.0.0.qualifier
-Bundle-ClassPath: .,
- lib/jetty-server-12.0.5.jar,
- lib/simpleclient_common-0.16.0.jar,
- lib/simpleclient_hotspot-0.16.0.jar,
- lib/simpleclient_httpserver-0.16.0.jar,
- lib/simpleclient_jetty-0.16.0.jar,
- lib/simpleclient_servlet-0.16.0.jar,
- lib/simpleclient-0.16.0.jar,
- lib/simpleclient_servlet_common-0.16.0.jar
-Bundle-Activator: com.tibco.bw.prometheus.monitor.Activator
-Bundle-Vendor: TIBCO Software Inc.
-Require-Bundle: com.tibco.bw.thor.management.common
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Bundle-ActivationPolicy: lazy
-Import-Package: .;version="1.0.200",
- com.tibco.bw.frwk.api;version="[1.0.0,2.0.0)",
- com.tibco.bw.runtime;version="[6.2.100,7.0.0)",
- com.tibco.bw.runtime.event;version="[6.2.100,7.0.0)",
- com.tibco.bw.sharedresource.http.inbound.api;version="6.2.700",
- com.tibco.bw.sharedresource.http.runtime.montr.dependencies;version="[6.2.100,7.0.0)",
- com.tibco.bw.sharedresource.runtime;version="6.2.700",
- com.tibco.bw.thor.management.common;version="1.4.900",
- com.tibco.bw.thor.management.model.node;version="1.2.900",
- com.tibco.bw.thor.runtime.api;version="1.2.900",
- com.tibco.neo.exception;version="2.6.2",
- io.micrometer.core.instrument,
- io.micrometer.core.instrument.binder.jvm,
- io.micrometer.core.instrument.binder.system,
- io.micrometer.prometheus,
- javax.servlet;version="2.10.0",
- javax.servlet.http;version="2.10.0",
- org.apache.http;version="4.10.0",
- org.apache.http.client;version="4.10.0",
- org.apache.http.client.config;version="4.10.0",
- org.apache.http.client.methods;version="4.10.0",
- org.apache.http.client.utils;version="4.10.0",
- org.apache.http.config;version="4.10.0",
- org.apache.http.conn;version="4.10.0",
- org.apache.http.cookie;version="4.10.0",
- org.apache.http.entity;version="4.10.0",
- org.apache.http.impl.client;version="4.10.0",
- org.apache.http.message;version="4.10.0",
- org.apache.http.util;version="4.10.0",
- org.eclipse.jetty.server;version="[9.0.0,9.9.0)",
- org.eclipse.jetty.servlet;version="[9.0.0,9.9.0)",
- org.eclipse.jetty.util.component;version="[9.0.0,9.9.0)",
- org.osgi.framework;version="[1.3.0,2.0.0)",
- org.osgi.service.event;version="[1.3.0,2.0.0)",
- org.osgi.util.tracker;version="1.5.1",
- org.slf4j;version="1.8.0"
-Export-Package: com.tibco.bw.prometheus.monitor.stats
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Prometheus Monitoring for BW application
+Bundle-SymbolicName: com.tibco.bw.prometheus.monitor
+Bundle-Version: 1.0.11.qualifier
+Bundle-ClassPath: .,
+ lib/jetty-server-12.0.5.jar,
+ lib/simpleclient_common-0.16.0.jar,
+ lib/simpleclient_hotspot-0.16.0.jar,
+ lib/simpleclient_httpserver-0.16.0.jar,
+ lib/simpleclient_jetty-0.16.0.jar,
+ lib/simpleclient_servlet-0.16.0.jar,
+ lib/simpleclient-0.16.0.jar,
+ lib/simpleclient_servlet_common-0.16.0.jar
+Bundle-Activator: com.tibco.bw.prometheus.monitor.Activator
+Bundle-Vendor: TIBCO Software Inc.
+Require-Bundle: com.tibco.bw.thor.management.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Import-Package: .,
+ com.tibco.bw.frwk.api,
+ com.tibco.bw.runtime,
+ com.tibco.bw.runtime.event,
+ com.tibco.bw.sharedresource.http.inbound.api,
+ com.tibco.bw.sharedresource.http.runtime.montr.dependencies,
+ com.tibco.bw.sharedresource.runtime,
+ com.tibco.bw.thor.management.common,
+ com.tibco.bw.thor.management.model.node,
+ com.tibco.bw.thor.runtime.api,
+ com.tibco.neo.exception,
+ io.micrometer.core.instrument,
+ io.micrometer.core.instrument.binder.system,
+ io.micrometer.prometheus,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.client.config,
+ org.apache.http.client.methods,
+ org.apache.http.client.utils,
+ org.apache.http.config,
+ org.apache.http.conn,
+ org.apache.http.cookie,
+ org.apache.http.entity,
+ org.apache.http.impl.client,
+ org.apache.http.message,
+ org.apache.http.util,
+ org.eclipse.jetty.server,
+ org.eclipse.jetty.server.handler,
+ org.eclipse.jetty.servlet,
+ org.eclipse.jetty.util.component,
+ org.osgi.framework,
+ org.osgi.service.event,
+ org.osgi.util.tracker,
+ org.slf4j
+Export-Package: com.tibco.bw.prometheus.monitor.stats
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/Activator.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/Activator.java
index cfda9e2..7bc5c78 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/Activator.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/Activator.java
@@ -34,27 +34,34 @@ public static BundleContext getContext() {
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
+
ConfigurationManager config = ConfigurationManager.getInstance();
+
if (config.isPrometheusEnabled()) {
logger.info("Starting the Prometheus Monitoring Bundle");
//register activity stats service
- Dictionary activityProp = new Hashtable<>();
- String[] activityStatsServiceNames = new String[] {EventHandler.class.getName(), ActivityStatsEventCollector.class.getName()};
- String[] activityEventTopics = new String[] {AuditEventConstants.ACTIVITY_AUDIT_EVENT_TYPE};
- activityProp.put(EventConstants.EVENT_TOPIC, activityEventTopics);
- activityProp.put(StatCollectionConstant.BW_EVENT_TYPE_PROPERTY, StatCollectionConstant.BW_EVENT_TYPE_PROPERTY_VALUE);
- context.registerService(activityStatsServiceNames, new ActivityStatsEventCollector(), activityProp);
+
+ if(config.isActivityEnabled()) {
+ Dictionary activityProp = new Hashtable<>();
+ String[] activityStatsServiceNames = new String[] {EventHandler.class.getName(), ActivityStatsEventCollector.class.getName()};
+ String[] activityEventTopics = new String[] {AuditEventConstants.ACTIVITY_AUDIT_EVENT_TYPE};
+ activityProp.put(EventConstants.EVENT_TOPIC, activityEventTopics);
+ activityProp.put(StatCollectionConstant.BW_EVENT_TYPE_PROPERTY, StatCollectionConstant.BW_EVENT_TYPE_PROPERTY_VALUE);
+ context.registerService(activityStatsServiceNames, new ActivityStatsEventCollector(), activityProp);
+ }
//register process stats service
Dictionary processProp = new Hashtable<>();
String[] processStatsServiceNames = new String[] {EventHandler.class.getName(), ProcessInstanceStatsEventCollector.class.getName()};
- String[] processEventTopics = new String[] {AuditEventConstants.PROCESS_INSTANCE_AUDIT_EVENT_TYPE};
+ String[] processEventTopics = new String[] {AuditEventConstants.PROCESS_INSTANCE_AUDIT_EVENT_TYPE};
+
processProp.put(EventConstants.EVENT_TOPIC, processEventTopics);
- processProp.put(StatCollectionConstant.BW_EVENT_TYPE_PROPERTY, StatCollectionConstant.BW_EVENT_TYPE_PROPERTY_VALUE);
+ processProp.put(StatCollectionConstant.BW_EVENT_TYPE_PROPERTY, StatCollectionConstant.BW_EVENT_TYPE_PROPERTY_VALUE);
context.registerService(processStatsServiceNames, new ProcessInstanceStatsEventCollector(), processProp);
-
+
+
BWPrometheusDataExporter.exportMetrics();
PrometheusCollector.run();
}
@@ -70,4 +77,6 @@ public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
-}
\ No newline at end of file
+}
+
+
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/BWPrometheusDataExporter.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/BWPrometheusDataExporter.java
index a363aa1..1ec5f8f 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/BWPrometheusDataExporter.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/BWPrometheusDataExporter.java
@@ -18,30 +18,29 @@
public class BWPrometheusDataExporter {
private final static Logger logger = LoggerFactory.getLogger(BWPrometheusDataExporter.class);
- public static boolean isHTTPMetricsEnabled;
- public static boolean isSystemMetricsEnabled;
+
public static PrometheusMeterRegistry httpRegistry = null;
public static int port = 9095;
private static Server server;
public static void exportMetrics() throws Exception{
- if(System.getenv("BW_PROMETHEUS_PORT") != null) {
- port = Integer.parseInt(System.getenv("BW_PROMETHEUS_PORT"));
- }
+
+ ConfigurationManager config = ConfigurationManager.getInstance();
+ port = config.getPrometheusPort();
server = new Server(port);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
- initMetrics();
+
CollectorRegistry cr = CollectorRegistry.defaultRegistry;
cr.register(new PrometheusCollector());
DefaultExports.initialize();
// enable http endpoint metrics
- if(isHTTPMetricsEnabled) {
+ if(config.isHTTPMetricsEnabled()) {
httpRegistry = BWMicrometerRegistryProvider.getInstance().prometheusRegistry;
}
@@ -52,11 +51,7 @@ public static void exportMetrics() throws Exception{
}
- private static void initMetrics() {
- if(System.getenv("BW_PROMETHEUS_HTTP_METRICS") != null) {
- isHTTPMetricsEnabled=true;
- }
- }
+
private static void initSystemMetrics(PrometheusMeterRegistry systemRegistry) {
ProcessorMetrics metrics = new ProcessorMetrics();
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/CollectorServlet.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/CollectorServlet.java
index 9e1b495..06d98ec 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/CollectorServlet.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/CollectorServlet.java
@@ -1,6 +1,5 @@
package com.tibco.bw.prometheus.monitor;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;
@@ -32,7 +31,6 @@ public CollectorServlet(CollectorRegistry cr, PrometheusMeterRegistry sRegistry,
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- final ByteArrayOutputStream stream = new ByteArrayOutputStream();
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType(TextFormat.CONTENT_TYPE_004);
Writer writer = response.getWriter();
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/ConfigurationManager.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/ConfigurationManager.java
index 70c4b58..d9f2493 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/ConfigurationManager.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/ConfigurationManager.java
@@ -12,17 +12,20 @@ public class ConfigurationManager {
private static final String BW_PROMETHEUS_ENABLE = "BW_PROMETHEUS_ENABLE";
private static final String BW_PROMETHEUS_DETAILS_ENABLE = "BW_PROMETHEUS_DETAILS_ENABLE";
+ private static final String BW_PROMETHEUS_ACTIVITY_ENABLE = "BW_PROMETHEUS_ACTIVITY_ENABLE";
+ private static final String BW_PROMETHEUS_PROMETHEUS_PORT = "BW_PROMETHEUS_PORT";
+ private static final String BW_PROMETHEUS_HTTP_METRICS = "BW_PROMETHEUS_HTTP_METRICS";
private boolean isPrometheusEnabled = false;
private boolean isActivityDetailedEnabled = true;
private boolean isProcessDetailedEnabled = true;
-
+ private boolean isActivityEnabled = true;
+ private int prometheusPort = 9095;
+ private boolean isHTTPMetricsEnabled = false;
private ConfigurationManager(){
- init();
-
-
+ init();
}
private void init() {
@@ -35,9 +38,43 @@ private void init() {
isProcessDetailedEnabled = false;
}
- logger.warn("isPrometheusEnabled: "+isPrometheusEnabled);
- logger.warn("isProcessDetailedEnabled: "+isProcessDetailedEnabled);
- logger.warn("isActivityDetailedEnabled: "+isActivityDetailedEnabled);
+ if ((System.getenv(BW_PROMETHEUS_ACTIVITY_ENABLE) != null && System.getenv(BW_PROMETHEUS_ACTIVITY_ENABLE).equalsIgnoreCase("false")) || (System.getProperty(BW_PROMETHEUS_ACTIVITY_ENABLE) != null && System.getProperty(BW_PROMETHEUS_ACTIVITY_ENABLE).equalsIgnoreCase("false"))) {
+ isActivityDetailedEnabled = false;
+ isActivityEnabled = false;
+ }
+
+
+ if ((System.getenv(BW_PROMETHEUS_HTTP_METRICS) != null && System.getenv(BW_PROMETHEUS_HTTP_METRICS).equalsIgnoreCase("true")) || (System.getProperty(BW_PROMETHEUS_HTTP_METRICS) != null && System.getProperty(BW_PROMETHEUS_HTTP_METRICS).equalsIgnoreCase("true"))) {
+
+ isHTTPMetricsEnabled =true;
+ }
+
+
+ try {
+ if (System.getenv(BW_PROMETHEUS_PROMETHEUS_PORT) != null){
+ prometheusPort = Integer.parseInt(System.getenv(BW_PROMETHEUS_PROMETHEUS_PORT));
+
+ }
+
+ if (System.getProperty(BW_PROMETHEUS_PROMETHEUS_PORT) != null){
+ prometheusPort = Integer.parseInt(System.getProperty(BW_PROMETHEUS_PROMETHEUS_PORT));
+
+ }
+ }catch(NumberFormatException ex ) {
+ if(logger.isWarnEnabled()) {
+ logger.warn("Prometheus port will be established as :"+prometheusPort);
+ }
+ }
+
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("isPrometheusEnabled: "+isPrometheusEnabled);
+ logger.debug("isProcessDetailedEnabled: "+isProcessDetailedEnabled);
+ logger.debug("isActivityDetailedEnabled: "+isActivityDetailedEnabled);
+ logger.debug("isActivityEnabled: "+isActivityEnabled);
+ }
+
+
}
@@ -76,7 +113,29 @@ public boolean isProcessDetailedEnabled() {
public void setProcessDetailedEnabled(boolean isProcessDetailedEnabled) {
this.isProcessDetailedEnabled = isProcessDetailedEnabled;
}
+
+ public boolean isActivityEnabled() {
+ return isActivityEnabled;
+ }
+
+ public void setActivityEnabled(boolean isActivityEnabled) {
+ this.isActivityEnabled = isActivityEnabled;
+ }
+
+ public int getPrometheusPort() {
+ return prometheusPort;
+ }
+
+ public boolean isHTTPMetricsEnabled() {
+ return isHTTPMetricsEnabled;
+ }
+
+ public void setHTTPMetricsEnabled(boolean isHTTPMetricsEnabled) {
+ this.isHTTPMetricsEnabled = isHTTPMetricsEnabled;
+ }
+
+
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/PrometheusCollector.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/PrometheusCollector.java
index 080754d..f880e5b 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/PrometheusCollector.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/PrometheusCollector.java
@@ -2,10 +2,6 @@
package com.tibco.bw.prometheus.monitor;
-import io.prometheus.client.Collector;
-import io.prometheus.client.exporter.HTTPServer;
-
-import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -18,14 +14,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.tibco.bw.prometheus.monitor.stats.ActivityStatsEventCollector;
-import com.tibco.bw.prometheus.monitor.stats.ProcessInstanceStatsEventCollector;
import com.tibco.bw.prometheus.monitor.util.Utils;
import com.tibco.bw.sharedresource.http.inbound.api.HttpConnector;
import com.tibco.bw.sharedresource.http.inbound.api.HttpServletApplicationModel;
import com.tibco.bw.sharedresource.runtime.ResourceReference;
import com.tibco.neo.exception.BaseException;
+import io.prometheus.client.Collector;
+
public class PrometheusCollector extends Collector {
private static Logger logger = LoggerFactory.getLogger(PrometheusCollector.class);
@@ -55,10 +51,6 @@ public static void run() {
@Override
public List collect() {
List mfs = new ArrayList();
- mfs.addAll(ActivityStatsEventCollector.getCollection());
- mfs.addAll(ProcessInstanceStatsEventCollector.getCollection());
- ActivityStatsEventCollector.reset();
- ProcessInstanceStatsEventCollector.reset();
return mfs;
}
@@ -76,7 +68,7 @@ private static boolean registerProxyServlet() throws BaseException {
HttpConnector connector = (HttpConnector) reference.getResource();
if (connector != null) {
HashMap initParams = new HashMap<>();
- initParams.put(ProxyServlet.P_TARGET_URI, "http://localhost:9095/metrics");
+ initParams.put(ProxyServlet.P_TARGET_URI, "http://localhost:"+ConfigurationManager.getInstance().getPrometheusPort()+"/metrics");
HttpServletApplicationModel model = new HttpServletApplicationModel("/metrics", "/*", APPLICATION_NAME, initParams, new ProxyServlet(proxyInitLatch));
connector.deployServletApplication(model);
logger.info("Prometheus : Proxy server created in PCF");
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ActivityStatsEventCollector.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ActivityStatsEventCollector.java
index 13ece60..5d98348 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ActivityStatsEventCollector.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ActivityStatsEventCollector.java
@@ -10,14 +10,8 @@
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.EVENT_DATA_PROPERTY;
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.START_TIME_PROPERTY;
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.STATUS_PROPERTY;
-import io.prometheus.client.Collector;
-import io.prometheus.client.Collector.MetricFamilySamples;
-import io.prometheus.client.Collector.MetricFamilySamples.Sample;
-import io.prometheus.client.Collector.Type;
-import io.prometheus.client.CounterMetricFamily;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,15 +32,25 @@
import com.tibco.bw.runtime.event.State;
import com.tibco.bw.thor.management.common.ContianerInfo;
+import io.prometheus.client.Collector;
+import io.prometheus.client.Collector.MetricFamilySamples.Sample;
+import io.prometheus.client.Counter;
+import io.prometheus.client.Gauge;
+
public class ActivityStatsEventCollector implements EventHandler {
-
+
private final static Logger logger = LoggerFactory.getLogger(ActivityStatsEventCollector.class);
-
private final ConcurrentMap> statMaps = new ConcurrentHashMap>();
- private ActivityStats activityStats = new ActivityStats();
+
+ static Map>> durationStatsMap = new HashMap>>();
+
private ContianerInfo deploymentInfo = ContianerInfo.get();
private ConfigurationManager config = ConfigurationManager.getInstance();
+ static final Counter activityStatsTotalCounter = Counter.build().name("activity_events_count").help("BWCE All Activity Events count by Process, Activity State").labelNames("ProcessName", "ActivityName", "StateName").register();
+ static final Gauge activityDurationCounter = Gauge.build().name("activity_duration_count").help("BWCE Activity DurationTime by Process and Activity").labelNames("ProcessName", "ActivityName").register();
+ static final Gauge activityEvaltimeCounter = Gauge.build().name("activity_evaltime_count").help("BWCE Activity EvalTime by Process and Activity ").labelNames("ProcessName", "ActivityName").register();
+
static Map activityStateCounterMap = new HashMap();
static {
activityStateCounterMap.put(State.STARTED.name(), 0);
@@ -54,90 +58,81 @@ public class ActivityStatsEventCollector implements EventHandler {
activityStateCounterMap.put(State.FAULTED.name(), 0);
activityStateCounterMap.put(State.CANCELLED.name(), 0);
}
-
-
- static Map> activityCounterMap = new HashMap>();
-
+
+
private static List activitySampleList = new ArrayList();
private static List activityCounterSampleList = new ArrayList();
-
- @Override
- public void handleEvent(final Event event) {
- if (logger.isDebugEnabled()) {
- logger.debug("Event Received. Event = {" + event.toString() + "}");
- }
- ActivityAuditEvent activityEvent = (ActivityAuditEvent) event.getProperty(EVENT_DATA_PROPERTY);
- String pId = activityEvent.getProcessInstanceId();
- String activityName = activityEvent.getActivityName();
- String activityExecutionId = activityEvent.getActivityExecutionId();
- String key = activityName + pId + activityExecutionId;
+ @Override
+ public void handleEvent(final Event event) {
+
+ if (config.isPrometheusEnabled() && config.isActivityEnabled()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Event Received. Event = {" + event.toString() + "}");
+ }
+
+
+ if (event.getProperty(EVENT_DATA_PROPERTY) instanceof ActivityAuditEvent) {
+ ActivityAuditEvent activityEvent = (ActivityAuditEvent) event.getProperty(EVENT_DATA_PROPERTY);
+
+
+ String pId = activityEvent.getProcessInstanceId();
+ String activityName = activityEvent.getActivityName();
+ String activityExecutionId = activityEvent.getActivityExecutionId();
+ String key = activityName + pId + activityExecutionId;
+
if(config.isActivityDetailedEnabled()){
activityCounterSampleList.add(new Sample("activity_state_count",ActivityStats.getActivityCounterKeyList(), getActivityStateCounterList(activityEvent), 1));
}
updateTotalActivityEventCounter(activityEvent.getActivityState().name());
- updateActivityCounter(activityEvent);
-
- if (State.STARTED == activityEvent.getActivityState()) {
- Map activityStatMap = new HashMap();
- for (String proprtyName : event.getPropertyNames()) {
- activityStatMap.put(proprtyName, event.getProperty(proprtyName));
- }
- if (null == statMaps.get(key)) {
- activityStatMap.put(START_TIME_PROPERTY,(activityEvent.getActivityStartTime()));
- try {
- activityStatMap.put("activityInput",activityEvent.getSerializedInputData());
- } catch (ActivityInputDataException e) {
- logger.error("Error while accessing activity input data " + e.getMessage());
- }
- statMaps.put(key, activityStatMap);
- } else {
- activityStatMap = statMaps.remove(key);
- activityStatMap.put(START_TIME_PROPERTY,(activityEvent.getActivityStartTime()));
- addStatsToMetrics(activityStatMap, activityEvent);
- }
- } else if (State.COMPLETED == activityEvent.getActivityState()
- || State.FAULTED == activityEvent.getActivityState()
- || State.CANCELLED == activityEvent.getActivityState()) {
-
- Map activityStatMap = new HashMap();
- if (null == statMaps.get(key)) {
+ updateActivityCounter(activityEvent);
- activityStatMap.put(END_TIME_PROPERTY,(activityEvent.getActivityEndTime()));
- activityStatMap.put(EVAL_TIME_PROPERTY,(activityEvent.getActivityEvalTime()));
- activityStatMap.put(STATUS_PROPERTY, activityEvent.getActivityState().name());
- try {
- activityStatMap.put("activityOutput",activityEvent.getSerializedOutputData());
- } catch (ActivityOutputDataException e) {
- logger.error("Error while accessing activity output data " + e.getMessage());
- }
- statMaps.put(key, activityStatMap);
- } else {
- if (logger.isDebugEnabled()) {
+ if (State.STARTED == activityEvent.getActivityState()) {
+ Map activityStatMap = new HashMap();
+ for (String proprtyName : event.getPropertyNames()) {
+ activityStatMap.put(proprtyName, event.getProperty(proprtyName));
+ }
+ if (null == statMaps.get(key)) {
+ activityStatMap.put(START_TIME_PROPERTY, (activityEvent.getActivityStartTime()));
+ try {
+ activityStatMap.put("activityInput", activityEvent.getSerializedInputData());
+ } catch (ActivityInputDataException e) {
+ logger.error("Error while accessing activity input data " + e.getMessage());
+ }
+ statMaps.put(key, activityStatMap);
+ } else {
+ activityStatMap = statMaps.remove(key);
+ activityStatMap.put(START_TIME_PROPERTY, (activityEvent.getActivityStartTime()));
+ addStatsToMetrics(activityStatMap, activityEvent);
+ }
+ } else if (State.COMPLETED == activityEvent.getActivityState()
+ || State.FAULTED == activityEvent.getActivityState()
+ || State.CANCELLED == activityEvent.getActivityState()) {
+ Map activityStatMap = new HashMap();
+ if (null == statMaps.get(key)) {
+ activityStatMap.put(END_TIME_PROPERTY, (activityEvent.getActivityEndTime()));
+ activityStatMap.put(EVAL_TIME_PROPERTY, (activityEvent.getActivityEvalTime()));
+ activityStatMap.put(STATUS_PROPERTY, activityEvent.getActivityState().name());
+ try {
+ activityStatMap.put("activityOutput", activityEvent.getSerializedOutputData());
+ } catch (ActivityOutputDataException e) {
+ logger.error("Error while accessing activity output data " + e.getMessage());
+ }
+ statMaps.put(key, activityStatMap);
+ } else {
+ if (logger.isDebugEnabled()) {
logger.debug("Statistics collected for Activity {" + activityName + "} in Process Instance {" + pId + "}");
+ }
+ activityStatMap = statMaps.remove(key);
+ activityStatMap.put(STATUS_PROPERTY, activityEvent.getActivityState().name());
+ addStatsToMetrics(activityStatMap, activityEvent);
+ }
}
- activityStatMap = statMaps.remove(key);
- activityStatMap.put(STATUS_PROPERTY, activityEvent.getActivityState().name());
- addStatsToMetrics(activityStatMap, activityEvent);
+
}
}
}
- private void updateActivityCounter(ActivityAuditEvent activityEvent) {
- String key=activityEvent.getProcessName()+"#"+activityEvent.getActivityName();
- HashMap mapAct = activityCounterMap.get(key);
- if(mapAct == null){
- mapAct = new HashMap();
- }
- Integer value = mapAct.get(activityEvent.getActivityState().name());
- if(value == null){
- mapAct.put(activityEvent.getActivityState().name(), 1);
- }else{
- mapAct.put(activityEvent.getActivityState().name(), value + 1);
- }
- activityCounterMap.put(key, mapAct);
-
- }
private List getActivityStateCounterList(ActivityAuditEvent event) {
List stateList = new ArrayList<>();
@@ -152,15 +147,28 @@ private List getActivityStateCounterList(ActivityAuditEvent event) {
return stateList;
}
+ private void updateTotalAcitivtyDurationCounter(ActivityStats activityStats2) {
+ activityDurationCounter.labels(activityStats2.getProcessName(),activityStats2.getActivityName()).inc(activityStats2.getActivityDurationTime());
+ activityEvaltimeCounter.labels(activityStats2.getProcessName(),activityStats2.getActivityName()).inc(activityStats2.getActivityEvalTime());
+ }
+
private void updateTotalActivityEventCounter(String name) {
if(activityStateCounterMap.containsKey(name)){
activityStateCounterMap.put(name, activityStateCounterMap.get(name) + 1);
}
}
+ private void updateActivityCounter(ActivityAuditEvent activityEvent) {
+ activityStatsTotalCounter.labels(activityEvent.getProcessName(),activityEvent.getActivityName(),activityEvent.getActivityState().name()).inc();
+ }
+
+
+
+
+
private void addStatsToMetrics(final Map pStatMap,
final ActivityAuditEvent event) {
-
+ ActivityStats activityStats = new ActivityStats();
activityStats.setApplicationName(event.getApplicationName());
activityStats.setApplicationVersion(event.getApplicationVersion());
activityStats.setModuleName(event.getModuleName());
@@ -195,56 +203,15 @@ private void addStatsToMetrics(final Map pStatMap,
activityStats.setAppspaceName(System.getProperty(BW_APPSPACE_PROPERTY));
activityStats.setDomainName(System.getProperty(BW_DOMAIN_PROPERTY));
activityStats.setActivityExecutionId(event.getActivityExecutionId());
-
- //Add Activity in Metrics
+
+ // Add Activity in Metrics
if(config.isActivityDetailedEnabled()){
activitySampleList.add(new Sample("activity_stats_total", ActivityStats.getActivityStatsKeyList(), activityStats.getActivityStatsValueList(), 1));
activityCounterSampleList.add(new Sample("activity_duration_count",ActivityStats.getActivityCounterKeyList(), activityStats.getActivityCounterValueList(), activityStats.getActivityDurationTime()));
activityCounterSampleList.add(new Sample("activity_evaltime_count",ActivityStats.getActivityCounterKeyList(), activityStats.getActivityCounterValueList(), activityStats.getActivityEvalTime()));
}
- }
-
- public static List getCollection() {
-
- List copyActivitySampleList = new ArrayList<>();
- copyActivitySampleList.addAll(activitySampleList);
- MetricFamilySamples activityMFS = new MetricFamilySamples("bwce_activity_stats_list",
- Type.GAUGE, "BWCE Activity Statictics list",copyActivitySampleList);
-
-
- List copyActivityCounterSampleList = new ArrayList<>();
- copyActivityCounterSampleList.addAll(activityCounterSampleList);
- MetricFamilySamples activityCountersMFS = new MetricFamilySamples("bwce_activity_counter_list",
- Type.GAUGE, "BWCE Activity related Counters list",copyActivityCounterSampleList);
-
- CounterMetricFamily allActivityEventCounter = new CounterMetricFamily("all_activity_events_count", "BWCE All Activity Events count by State",Arrays.asList("StateName"));
- allActivityEventCounter.addMetric(Arrays.asList(State.CANCELLED.name()), activityStateCounterMap.get(State.CANCELLED.name()));
- allActivityEventCounter.addMetric(Arrays.asList(State.COMPLETED.name()), activityStateCounterMap.get(State.COMPLETED.name()));
- allActivityEventCounter.addMetric(Arrays.asList(State.STARTED.name()), activityStateCounterMap.get(State.STARTED.name()));
- allActivityEventCounter.addMetric(Arrays.asList(State.FAULTED.name()), activityStateCounterMap.get(State.FAULTED.name()));
-
- CounterMetricFamily activityEventCounter = new CounterMetricFamily("activity_events_count", "BWCE All Activity Events count by Process, Activity State",Arrays.asList("ProcessName","ActivityName","StateName"));
- for(String entry : activityCounterMap.keySet()){
- for(String state : activityCounterMap.get(entry).keySet()){
- String[] keyParts = entry.split("#");
- if(keyParts.length > 1){
- activityEventCounter.addMetric(Arrays.asList(keyParts[0],keyParts[1],state), activityCounterMap.get(entry).get(state));
- }
- }
- }
-
-
- List mfs = new ArrayList<>();
- mfs.add(activityMFS);
- mfs.add(activityCountersMFS);
- mfs.add(allActivityEventCounter);
- mfs.add(activityEventCounter);
- return mfs;
- }
- public static void reset(){
- activityCounterSampleList.clear();
- activitySampleList.clear();
+ updateTotalAcitivtyDurationCounter(activityStats);
}
}
diff --git a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ProcessInstanceStatsEventCollector.java b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ProcessInstanceStatsEventCollector.java
index c848b8b..de9d9cb 100644
--- a/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ProcessInstanceStatsEventCollector.java
+++ b/prometheus-integration/com.tibco.bw.prometheus.monitor/src/com/tibco/bw/prometheus/monitor/stats/ProcessInstanceStatsEventCollector.java
@@ -7,19 +7,12 @@
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.EVENT_DATA_PROPERTY;
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.START_TIME_PROPERTY;
import static com.tibco.bw.prometheus.monitor.util.StatCollectionConstant.STATUS_PROPERTY;
-import io.prometheus.client.Collector;
-import io.prometheus.client.Collector.MetricFamilySamples;
-import io.prometheus.client.Collector.MetricFamilySamples.Sample;
-import io.prometheus.client.Collector.Type;
-import io.prometheus.client.CounterMetricFamily;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
@@ -32,6 +25,9 @@
import com.tibco.bw.runtime.event.State;
import com.tibco.bw.thor.management.common.ContianerInfo;
+import io.prometheus.client.Counter;
+import io.prometheus.client.Gauge;
+
public class ProcessInstanceStatsEventCollector implements EventHandler {
private final static Logger logger = LoggerFactory.getLogger(ProcessInstanceStatsEventCollector.class);
@@ -43,226 +39,129 @@ public class ProcessInstanceStatsEventCollector implements EventHandler {
private final ConcurrentMap> statMaps = new ConcurrentHashMap>();
private ContianerInfo deploymentInfo = ContianerInfo.get();
- private static List processSampleList = new ArrayList();
- private static List processCounterSampleList = new ArrayList();
- static Map processStateCounterMap = new HashMap();
- static {
- processStateCounterMap.put(State.STARTED.name(), 0);
- processStateCounterMap.put(State.COMPLETED.name(), 0);
- processStateCounterMap.put(State.FAULTED.name(), 0);
- processStateCounterMap.put(State.CANCELLED.name(), 0);
- }
-
- static Map> processCounterMap = new HashMap>();
-
-
+ static final Counter processStatsTotalCounter = Counter.build().name("process_events_count").help("BWCE Process Events count by Process").labelNames("ProcessName", "StateName").register();
+ static final Gauge processDurationCounter = Gauge.build().name("process_duration_milliseconds_total").help("BWCE Process Events duration by Process in milliseconds").labelNames("ProcessName").register();
+
@Override
public void handleEvent(final Event event) {
- if (logger.isDebugEnabled()) {
- logger.debug("Event Received. Event = {"+ event.toString() + "}");
- }
-
- ProcessAuditEvent processEvent = (ProcessAuditEvent) event.getProperty(EVENT_DATA_PROPERTY);
- String pId = processEvent.getProcessInstanceId();
- if (processEvent.getProcessInstanceState() != State.INFORMATIVE) {
- if(config.isProcessDetailedEnabled()){
- processCounterSampleList.add(new Sample("process_state_count",ProcessStats.getProcessCounterKeyList(), getProcessStateCounterList(processEvent), 1));
- }
- }
- updateProcessEventCounter(processEvent.getProcessInstanceState().name());
- updateProcessCounter(processEvent);
-
- if (State.STARTED == processEvent.getProcessInstanceState()) {
- Map processStatMap = new HashMap();
- for (String propName : event.getPropertyNames()) {
- processStatMap.put(propName, event.getProperty(propName));
- }
- if (null == statMaps.get(pId)) {
- processStatMap.put(START_TIME_PROPERTY, processEvent.getProcessInstanceStartTime());
- statMaps.put(pId, processStatMap);
- } else {
- processStatMap = statMaps.remove(pId);
- processStatMap.put(START_TIME_PROPERTY,processEvent.getProcessInstanceStartTime());
- addStatsToMetrics(processStatMap, processEvent);
+ if (config.isPrometheusEnabled()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Event Received. Event = {" + event.toString() + "}");
}
- } else if (State.COMPLETED == processEvent.getProcessInstanceState()
- || State.FAULTED == processEvent.getProcessInstanceState()
- || State.CANCELLED == processEvent.getProcessInstanceState()) {
- Map processStatMap = new HashMap();
- processStatMap.put(STATUS_PROPERTY, processEvent.getProcessInstanceState().name());
- if (null == statMaps.get(pId)) {
- processStatMap.put(EVAL_TIME_PROPERTY, "null");
- processStatMap.put(END_TIME_PROPERTY,processEvent.getProcessInstanceEndTime());
- statMaps.put(pId, processStatMap);
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Statistics collected for process instance {" + pId + "}");
+ if (event.getProperty(EVENT_DATA_PROPERTY) instanceof ProcessAuditEvent) {
+ ProcessAuditEvent processEvent = (ProcessAuditEvent) event.getProperty(EVENT_DATA_PROPERTY);
+ String pId = processEvent.getProcessInstanceId();
+ if (processEvent.getProcessInstanceState() != State.INFORMATIVE && processEvent.getProcessInstanceState() != State.SCHEDULED) {
+ updateProcessCounter(processEvent);
+
+ if (State.STARTED == processEvent.getProcessInstanceState()) {
+
+ Map processStatMap = new HashMap();
+ for (String propName : event.getPropertyNames()) {
+ processStatMap.put(propName, event.getProperty(propName));
+ }
+ if (null == statMaps.get(pId)) {
+ processStatMap.put(START_TIME_PROPERTY, processEvent.getProcessInstanceStartTime());
+ statMaps.put(pId, processStatMap);
+ } else {
+ processStatMap = statMaps.remove(pId);
+ processStatMap.put(START_TIME_PROPERTY, processEvent.getProcessInstanceStartTime());
+ addStatsToMetrics(processStatMap, processEvent);
+ }
+ } else if (State.COMPLETED == processEvent.getProcessInstanceState()
+ || State.FAULTED == processEvent.getProcessInstanceState()
+ || State.CANCELLED == processEvent.getProcessInstanceState()) {
+ Map processStatMap = new HashMap();
+ processStatMap.put(STATUS_PROPERTY, processEvent.getProcessInstanceState().name());
+ if (null == statMaps.get(pId)) {
+ processStatMap.put(EVAL_TIME_PROPERTY, "null");
+ processStatMap.put(END_TIME_PROPERTY, processEvent.getProcessInstanceEndTime());
+ statMaps.put(pId, processStatMap);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Statistics collected for process instance {" + pId + "}");
+ }
+ processStatMap = statMaps.remove(pId);
+ addStatsToMetrics(processStatMap, processEvent);
+ }
+ }
}
- processStatMap = statMaps.remove(pId);
- addStatsToMetrics(processStatMap, processEvent);
}
- }
+ }
}
- private List getProcessStateCounterList(
- ProcessAuditEvent event) {
- List stateList = new ArrayList<>();
- stateList.add(event.getApplicationName());
- stateList.add(event.getProcessName());
- stateList.add(event.getProcessInstanceId());
- if (event.getProcessInstanceStartTime() != null)
- stateList.add(Utils.convertTimeToString(event.getProcessInstanceStartTime()));
- else
- stateList.add(Utils.convertTimeToString(event.getProcessInstanceEndTime()));
- stateList.add(event.getProcessInstanceState().name());
- return stateList;
- }
- private void updateProcessEventCounter(String name) {
- if(processStateCounterMap.containsKey(name)){
- processStateCounterMap.put(name, processStateCounterMap.get(name) + 1);
- }else{
- processStateCounterMap.put(name, 1);
- }
- }
-
-
private void updateProcessCounter(ProcessAuditEvent audit) {
- HashMap map = processCounterMap.get(audit.getProcessName());
- if(map == null){
- map = new HashMap();
- }
-
- Integer value = map.get(audit.getProcessInstanceState().name());
- if(value == null){
- value = 0;
-
+ processStatsTotalCounter.labels(audit.getProcessName(),audit.getProcessInstanceState().name()).inc();
+ if (logger.isDebugEnabled()) {
+ logger.debug(audit.getProcessName() + ":"+audit.getProcessInstanceState().name()+":"+processStatsTotalCounter.labels(audit.getProcessName(),audit.getProcessInstanceState().name()).get());
}
- map.put(audit.getProcessInstanceState().name(), value + 1);
- processCounterMap.put(audit.getProcessName(), map);
-
}
-
+
private String getNonNullValue(final String value) {
return value != null ? value : "-";
}
private void addStatsToMetrics(final Map pStatMap,
final ProcessAuditEvent event) {
- try{
- ProcessStats pis = new ProcessStats();
- pis.setApplicationName(event.getApplicationName());
- pis.setApplicationVersion(event.getApplicationVersion());
- pis.setModuleName(event.getModuleName());
- pis.setModuleVersion(event.getModuleVersion());
+ try {
+ ProcessStats pis = new ProcessStats();
+ pis.setApplicationName(event.getApplicationName());
+ pis.setApplicationVersion(event.getApplicationVersion());
+ pis.setModuleName(event.getModuleName());
+ pis.setModuleVersion(event.getModuleVersion());
pis.setComponentProcessName(getNonNullValue(event
.getComponentProcessName()));
- pis.setJobId(event.getJobId());
- pis.setProcessName(event.getProcessName());
- if(event.getParentProcessName() == null && event.getParentProcessInstanceId() == null){
- pis.setParentProcessName("null");
- pis.setParentProcessInstanceId("null");
- } else {
- pis.setParentProcessName(event.getParentProcessName());
- pis.setParentProcessInstanceId(event.getParentProcessInstanceId());
- }
- pis.setProcessInstanceId(event.getProcessInstanceId());
- if (State.STARTED == event.getProcessInstanceState()) {
- pis.setProcessInstanceStartTime(Utils.convertTimeToString(event.getProcessInstanceStartTime()));
- pis.setProcessInstanceEndTime(Utils.convertTimeToString((Long) pStatMap.get(END_TIME_PROPERTY)));
- pis.setProcessInstanceDurationTime((Long) pStatMap.get(END_TIME_PROPERTY) - event.getProcessInstanceEndTime());
- } else if (State.COMPLETED == event.getProcessInstanceState()
- || State.FAULTED == event.getProcessInstanceState()
- || State.CANCELLED == event.getProcessInstanceState()) {
- pis.setProcessInstanceStartTime(Utils.convertTimeToString((Long) pStatMap.get(START_TIME_PROPERTY)));
- pis.setProcessInstanceEndTime(Utils.convertTimeToString(event.getProcessInstanceEndTime()));
- pis.setProcessInstanceDurationTime((event.getProcessInstanceEndTime() - (Long) pStatMap.get(START_TIME_PROPERTY)));
- }
- pis.setProcessInstanceState(event.getProcessInstanceState().name());
- if (deploymentInfo.isBWCE()) {
- String containerName = deploymentInfo.getContainerName();
- if (containerName != null) {
- pis.setAppnodeName(containerName);
+ pis.setJobId(event.getJobId());
+ pis.setProcessName(event.getProcessName());
+ if (event.getParentProcessName() == null && event.getParentProcessInstanceId() == null) {
+ pis.setParentProcessName("null");
+ pis.setParentProcessInstanceId("null");
+ } else {
+ pis.setParentProcessName(event.getParentProcessName());
+ pis.setParentProcessInstanceId(event.getParentProcessInstanceId());
+ }
+ pis.setProcessInstanceId(event.getProcessInstanceId());
+ if (State.STARTED == event.getProcessInstanceState()) {
+ pis.setProcessInstanceStartTime(Utils.convertTimeToString(event.getProcessInstanceStartTime()));
+ pis.setProcessInstanceEndTime(Utils.convertTimeToString((Long) pStatMap.get(END_TIME_PROPERTY)));
+ if (event.getProcessInstanceEndTime() != null) {
+ pis.setProcessInstanceDurationTime((Long) pStatMap.get(END_TIME_PROPERTY) - event.getProcessInstanceEndTime());
+ }
+ } else if (State.COMPLETED == event.getProcessInstanceState()
+ || State.FAULTED == event.getProcessInstanceState()
+ || State.CANCELLED == event.getProcessInstanceState()) {
+ pis.setProcessInstanceStartTime(Utils.convertTimeToString((Long) pStatMap.get(START_TIME_PROPERTY)));
+ pis.setProcessInstanceEndTime(Utils.convertTimeToString(event.getProcessInstanceEndTime()));
+ pis.setProcessInstanceDurationTime((event.getProcessInstanceEndTime() - (Long) pStatMap.get(START_TIME_PROPERTY)));
+ updateProcessDurationCounter(pis);
+ }
+ pis.setProcessInstanceState(event.getProcessInstanceState().name());
+ if (deploymentInfo.isBWCE()) {
+ String containerName = deploymentInfo.getContainerName();
+ if (containerName != null) {
+ pis.setAppnodeName(containerName);
+ } else {
+ pis.setAppnodeName(System.getProperty(BW_APPNODE_PROPERTY));
+ }
} else {
pis.setAppnodeName(System.getProperty(BW_APPNODE_PROPERTY));
}
- } else {
- pis.setAppnodeName(System.getProperty(BW_APPNODE_PROPERTY));
- }
- pis.setAppspaceName(System.getProperty(BW_APPSPACE_PROPERTY));
- pis.setDomainName(System.getProperty(BW_DOMAIN_PROPERTY));
-
- //setting null as subprocess details are not required.
- pis.setActivityExecutionId("null");
-
-// if (event.getParentProcessInstanceId() != null) {
-// pis.setActivityExecutionId(subProcessInfoMap.remove(event.getParentProcessInstanceId()
-// + event.getProcessInstanceId()));
-// } else {
-// pis.setActivityExecutionId("null");
-// }
-
- // Add Metrics
-
- if(config.isProcessDetailedEnabled()){
- processSampleList.add(new Sample("process_stats_total", ProcessStats.getProcessStatsKeyList(), pis.getProcessStatsValueList(), 1));
- processCounterSampleList.add(new Sample("process_duration_count",ProcessStats.getProcessCounterKeyList(), pis.getProcessCounterValueList(), pis.getProcessInstanceDurationTime()));
- }
+ pis.setAppspaceName(System.getProperty(BW_APPSPACE_PROPERTY));
+ pis.setDomainName(System.getProperty(BW_DOMAIN_PROPERTY));
+ pis.setActivityExecutionId("null");
- }catch(Throwable ex){
+ } catch (Throwable ex) {
logger.warn("Exception error handling Process Metrics", ex);
-
- }
- }
-
- public static List getCollection() {
-
-
-
-
- List copyProcessSampleList = new ArrayList<>();
- copyProcessSampleList.addAll(processSampleList);
-
- MetricFamilySamples processMFS = new MetricFamilySamples("bwce_process_stats",
- Type.GAUGE, "BWCE Process Statistics list", copyProcessSampleList);
-
-
-
- List copyProcessCounterSampleList = new ArrayList<>();
- copyProcessCounterSampleList.addAll(processCounterSampleList);
-
- MetricFamilySamples processCountersMFS = new MetricFamilySamples("bwce_process_counter_list",
- Type.GAUGE, "BWCE Process related Counters list", copyProcessCounterSampleList);
-
-
-
- CounterMetricFamily allProcessEventCounter = new CounterMetricFamily("all_process_events_count", "BWCE All Process Events count by State",Arrays.asList("StateName"));
- allProcessEventCounter.addMetric(Arrays.asList(State.CANCELLED.name()), processStateCounterMap.get(State.CANCELLED.name()));
- allProcessEventCounter.addMetric(Arrays.asList(State.COMPLETED.name()), processStateCounterMap.get(State.COMPLETED.name()));
- allProcessEventCounter.addMetric(Arrays.asList(State.STARTED.name()), processStateCounterMap.get(State.STARTED.name()));
- allProcessEventCounter.addMetric(Arrays.asList(State.FAULTED.name()), processStateCounterMap.get(State.FAULTED.name()));
-
-
- CounterMetricFamily processEventCounter = new CounterMetricFamily("process_events_count", "BWCE Process Events count by Process",Arrays.asList("ProcessName","StateName"));
- for(String entry : processCounterMap.keySet()){
- for(String state : processCounterMap.get(entry).keySet()){
- processEventCounter.addMetric(Arrays.asList(entry,state) , processCounterMap.get(entry).get(state));
- }
+
}
-
-
- List mfs = new ArrayList<>();
- mfs.add(processMFS);
- mfs.add(processCountersMFS);
- mfs.add(allProcessEventCounter);
- mfs.add(processEventCounter);
- return mfs;
}
-
- public static void reset(){
- processCounterSampleList.clear();
- processSampleList.clear();
+
+ private void updateProcessDurationCounter(ProcessStats pis) {
+ processDurationCounter.labels(pis.getProcessName()).inc(pis.getProcessInstanceDurationTime());
}
+
+
}
diff --git a/prometheus-integration/sample/prometheus-integration-1.0.11.jar b/prometheus-integration/sample/prometheus-integration-1.0.11.jar
new file mode 100644
index 0000000..27f425f
Binary files /dev/null and b/prometheus-integration/sample/prometheus-integration-1.0.11.jar differ