Enabling Prometheus metrics on WSO2 Micro-Integrator

huangapple go评论75阅读模式
英文:

Enabling Prometheus metrics on WSO2 Micro-Integrator

问题

I have a MI instance 4.1.0 with a port offset of 20 running on RHEL VM (no containerization). The MI instance is listening on port 9211.

$ grep offset deployment.toml
offset = 20
$ netstat -tulpn | grep java
tcp 0 0 0.0.0.0:8300 0.0.0.0:* LISTEN 18874/java
tcp 0 0 0.0.0.0:9174 0.0.0.0:* LISTEN 18874/java
tcp 0 0 0.0.0.0:9211 0.0.0.0:* LISTEN 18874/java
tcp 0 0 0.0.0.0:35932 0.0.0.0:* LISTEN 18874/java
tcp 0 0 0.0.0.0:8263 0.0.0.0:* LISTEN 18874/java

When starting MI as follows and checking with curl

$ ./micro-integrator.sh -DenablePrometheusApi
$ curl -v http://XXX:9211/metric-service/metrics

  • About to connect() to XXX port 9211 (#0)

GET /metric-service/metrics HTTP/1.1
User-Agent: curl/7.29.0
Host: XXX:9211
< HTTP/1.1 200 OK
< Host: git-chqbiz01:9211
< Content-Type: text/plain; charset=UTF-8
< Date: Mon, 22 May 2023 07:45:48 GMT
< Transfer-Encoding: chunked
<

There is not a single metric being reported (reply is empty).
No error messages appear in the logfile

Shouldn't I see the list of default metrics? Is there additional configuration required? I simply followed the instructions in the following link: https://docs.wso2.com/display/EI650/Monitoring+WSO2+Micro+Integrator

If I alter the micro-integrator.sh to add -DenablePrometheusApi and launch micro-integrator.sh, then I get an HTTP 404 with the following log lines.

2023-05-22 15:58:15,722] WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to: /metric-service/metrics
[2023-05-22 15:58:21,375] WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to: /metric-service/metrics
[2023-05-22 15:58:23,281] WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to: /metric-service/metrics
[2023-05-22 15:58:39,322] WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to: /metric-service/metrics

英文:

I have a MI instance 4.1.0 with a port offset of 20 running on RHEL VM (no containerizaion). The MI instance is listening on port 9211

$ grep offset deployment.toml
offset  = 20
$ netstat -tulpn  | grep java
tcp        0      0 0.0.0.0:8300            0.0.0.0:*               LISTEN      18874/java
tcp        0      0 0.0.0.0:9174            0.0.0.0:*               LISTEN      18874/java
tcp        0      0 0.0.0.0:9211            0.0.0.0:*               LISTEN      18874/java
tcp        0      0 0.0.0.0:35932           0.0.0.0:*               LISTEN      18874/java
tcp        0      0 0.0.0.0:8263            0.0.0.0:*               LISTEN      18874/java

When starting MI as follows and checking with curl

$ ./micro-integrator.sh -DenablePrometheusApi
$ curl -v http://XXX:9211/metric-service/metrics
		* About to connect() to XXX port 9211 (#0)
		&gt; GET /metric-service/metrics HTTP/1.1
		&gt; User-Agent: curl/7.29.0
		&gt; Host: XXX:9211
		&lt; HTTP/1.1 200 OK
		&lt; Host: git-chqbiz01:9211
		&lt; Content-Type: text/plain; charset=UTF-8
		&lt; Date: Mon, 22 May 2023 07:45:48 GMT
		&lt; Transfer-Encoding: chunked
		&lt;

There is not a single metrics being reported (reply is empty).
No error messages appear in the logfile

Shouldn't I see the list of default metrics? Is there an additional configuration required? I simply followed the instructions of following link : https://docs.wso2.com/display/EI650/Monitoring+WSO2+Micro+Integrator

If I alter the micro-integrator.sh to add a -DenablePrometheusApi and launch micro-integrator.sh, then I get a HTTP 404 with following log lines.

2023-05-22 15:58:15,722]  WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to : /metric-service/metrics
[2023-05-22 15:58:21,375]  WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to : /metric-service/metrics
[2023-05-22 15:58:23,281]  WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to : /metric-service/metrics
[2023-05-22 15:58:39,322]  WARN {InternalAPIDispatcher} - No Internal API found to dispatch the message to : /metric-service/metrics

答案1

得分: 1

已将自定义处理程序添加到 deployment.toml 吗?然后使用 -DenablePrometheusApi=true 标志启动服务器吗?

[[synapse_handlers]]
name="CustomObservabilityHandler"
class="org.wso2.micro.integrator.observability.metric.handler.MetricHandler"

这里是最新的文档。

如果您想要永久添加此标志,可以将其添加到 integrator.sh,如下所示。

while [ "$status" = "$START_EXIT_STATUS" ]
do
    $JAVACMD \
    -Xbootclasspath/a:"$CARBON_XBOOTCLASSPATH" \
    $JVM_MEM_OPTS \
    -XX:+HeapDumpOnOutOfMemoryError \
    -XX:HeapDumpPath="$CARBON_HOME/repository/logs/heap-dump.hprof" \
    $JAVA_OPTS \
    -Dcom.sun.management.jmxremote \
    -classpath "$CARBON_CLASSPATH" \
    -Djava.io.tmpdir="$CARBON_HOME/tmp" \
    -Dcatalina.base="$CARBON_HOME/wso2/lib/tomcat" \
    -Dwso2.server.standalone=true \
    -Dcarbon.registry.root=/ \
    -Djava.command="$JAVACMD" \
    -Dqpid.conf="/conf/advanced/" \
    $JAVA_VER_BASED_OPTS \
    -Dcarbon.home="$CARBON_HOME" \
    -Dlogger.server.name="micro-integrator" \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Dcarbon.config.dir.path="$CARBON_HOME/conf" \
    -Dcarbon.repository.dir.path="$CARBON_HOME/repository" \
    -Dcarbon.components.dir.path="$CARBON_HOME/wso2/components" \
    -Dcarbon.dropins.dir.path="$CARBON_HOME/dropins" \
    -Dcarbon.external.lib.dir.path="$CARBON_HOME/lib" \
    -Dcarbon.patches.dir.path="$CARBON_HOME/patches" \
    -Dcarbon.internal.lib.dir.path="$CARBON_HOME/wso2/lib" \
    -Dei.extendedURIBasedDispatcher=org.wso2.micro.integrator.core.handlers.IntegratorStatefulHandler \
    -Djava.util.logging.config.file="$CARBON_HOME/conf/etc/logging-bridge.properties" \
    -Dcomponents.repo="$CARBON_HOME/wso2/components/plugins" \
    -Dconf.location="$CARBON_HOME/conf" \
    -Dcom.atomikos.icatch.file="$CARBON_HOME/wso2/lib/transactions.properties" \
    -Dcom.atomikos.icatch.hide_init_file_path=true \
    -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false \
    -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true \
    -Dcom.sun.jndi.ldap.connect.pool.authentication=simple  \
    -Dcom.sun.jndi.ldap.connect.pool.timeout=3000  \
    -Dorg.terracotta.quartz.skipUpdateCheck=true \
    -Djava.security.egd=file:/dev/./urandom \
    -Dfile.encoding=UTF8 \
    -Djava.net.preferIPv4Stack=true \
    -DNonRegistryMode=true \
    -DNonUserCoreMode=true \
    -Dcom.ibm.cacheLocalHost=true \
    -Dcarbon.use.registry.repo=false \
    -DworkerNode=false \
    -Dorg.apache.cxf.io.CachedOutputStream.Threshold=104857600 \
    -Djavax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=net.sf.saxon.xpath.XPathFactoryImpl \
    -DavoidConfigHashRead=true \
    -Dproperties.file.path=default \
    -DenableReadinessProbe=true \
    -DenableManagementApi=true \
    -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector \
    $NODE_PARAMS \
    -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" \
    -Dnashorn.args=--language=es6 \
    -DenablePrometheusApi=true \
    org.wso2.micro.integrator.bootstrap.Bootstrap $*
    status=$?
done
英文:

Have you added the custom handlers to deployment.toml? And then started the server with -DenablePrometheusApi=true flag?

[[synapse_handlers]]
name=&quot;CustomObservabilityHandler&quot;
class=&quot;org.wso2.micro.integrator.observability.metric.handler.MetricHandler&quot;

This is the latest document.

If you want to add this flag permanently you can add this to integrator.sh as shown below.

while [ &quot;$status&quot; = &quot;$START_EXIT_STATUS&quot; ]
do
    $JAVACMD \
    -Xbootclasspath/a:&quot;$CARBON_XBOOTCLASSPATH&quot; \
    $JVM_MEM_OPTS \
    -XX:+HeapDumpOnOutOfMemoryError \
    -XX:HeapDumpPath=&quot;$CARBON_HOME/repository/logs/heap-dump.hprof&quot; \
    $JAVA_OPTS \
    -Dcom.sun.management.jmxremote \
    -classpath &quot;$CARBON_CLASSPATH&quot; \
    -Djava.io.tmpdir=&quot;$CARBON_HOME/tmp&quot; \
    -Dcatalina.base=&quot;$CARBON_HOME/wso2/lib/tomcat&quot; \
    -Dwso2.server.standalone=true \
    -Dcarbon.registry.root=/ \
    -Djava.command=&quot;$JAVACMD&quot; \
    -Dqpid.conf=&quot;/conf/advanced/&quot; \
    $JAVA_VER_BASED_OPTS \
    -Dcarbon.home=&quot;$CARBON_HOME&quot; \
    -Dlogger.server.name=&quot;micro-integrator&quot; \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Dcarbon.config.dir.path=&quot;$CARBON_HOME/conf&quot; \
    -Dcarbon.repository.dir.path=&quot;$CARBON_HOME/repository&quot; \
    -Dcarbon.components.dir.path=&quot;$CARBON_HOME/wso2/components&quot; \
    -Dcarbon.dropins.dir.path=&quot;$CARBON_HOME/dropins&quot; \
    -Dcarbon.external.lib.dir.path=&quot;$CARBON_HOME/lib&quot; \
    -Dcarbon.patches.dir.path=&quot;$CARBON_HOME/patches&quot; \
    -Dcarbon.internal.lib.dir.path=&quot;$CARBON_HOME/wso2/lib&quot; \
    -Dei.extendedURIBasedDispatcher=org.wso2.micro.integrator.core.handlers.IntegratorStatefulHandler \
    -Djava.util.logging.config.file=&quot;$CARBON_HOME/conf/etc/logging-bridge.properties&quot; \
    -Dcomponents.repo=&quot;$CARBON_HOME/wso2/components/plugins&quot; \
    -Dconf.location=&quot;$CARBON_HOME/conf&quot; \
    -Dcom.atomikos.icatch.file=&quot;$CARBON_HOME/wso2/lib/transactions.properties&quot; \
    -Dcom.atomikos.icatch.hide_init_file_path=true \
    -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false \
    -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true \
    -Dcom.sun.jndi.ldap.connect.pool.authentication=simple  \
    -Dcom.sun.jndi.ldap.connect.pool.timeout=3000  \
    -Dorg.terracotta.quartz.skipUpdateCheck=true \
    -Djava.security.egd=file:/dev/./urandom \
    -Dfile.encoding=UTF8 \
    -Djava.net.preferIPv4Stack=true \
    -DNonRegistryMode=true \
    -DNonUserCoreMode=true \
    -Dcom.ibm.cacheLocalHost=true \
    -Dcarbon.use.registry.repo=false \
    -DworkerNode=false \
    -Dorg.apache.cxf.io.CachedOutputStream.Threshold=104857600 \
    -Djavax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=net.sf.saxon.xpath.XPathFactoryImpl \
    -DavoidConfigHashRead=true \
    -Dproperties.file.path=default \
    -DenableReadinessProbe=true \
    -DenableManagementApi=true \
    -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector \
    $NODE_PARAMS \
    -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=&quot;*&quot; \
    -Dnashorn.args=--language=es6 \
    -DenablePrometheusApi=true \
    org.wso2.micro.integrator.bootstrap.Bootstrap $*
    status=$?
done

huangapple
  • 本文由 发表于 2023年5月22日 17:10:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304602.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定