Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions prometheus-integration/com.tibco.bw.prometheus.monitor/.classpath
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_servlet_common-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_common-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_hotspot-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_httpserver-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_jetty-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient_servlet-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/simpleclient-0.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jetty-server-12.0.5.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/simpleclient_hotspot-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient_common-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient_httpserver-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient_jetty-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient_servlet_common-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient_servlet-0.16.0.jar"/>
<classpathentry kind="lib" path="lib/simpleclient-0.16.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> 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<String, Object> 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<String, Object> 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();
}
Expand All @@ -70,4 +77,6 @@ public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}

}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tibco.bw.prometheus.monitor;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Writer;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}



}

Expand Down Expand Up @@ -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;
}






Expand Down
Loading