问题
I am following this tutorial to run Prometheus
on Windows10
. The tutorial is for linux
. I suppose the only command I need to change is for powershell
. However, when I try to access the metrics, the application doesn't connect.
https://www.robustperception.io/monitoring-cassandra-with-prometheus
Instead of echo 'JVM_OPTS="$JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.3.0.jar=7070:$PWD/cassandra.yml'"' >> conf/cassandra-env.sh
, I have added the following line in the cassandra-env.ps1
# Default JMX setup, bound to local loopback address only
$env:JVM_OPTS="$env:JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT"
$env:JVM_OPTS="$env:JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.3.0.jar=7070:$PWD/cassandra.yml'"' <-- HERE
$env:JVM_OPTS="$env:JVM_OPTS $env:JVM_EXTRA_OPTS"
}
but http://localhost:7070/metrics
doesn't work
UPDATE
Now, I have removed the changes from .sh
. and ps1
and add the javaagent
only in bin/cassanbra.bat
file as it seems that is what is required in Windows
https://docs.appdynamics.com/display/PRO45/Apache+Cassandra+Startup+Settings
But Now I get error
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NumberFormatException: For input string: "C"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:38)
... 6 more
FATAL ERROR in native method: processing of -javaagent failed
回答1:
Instead of this:
$env:JVM_OPTS="$env:JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.3.0.jar=7070:$PWD/cassandra.yml'"'
try this:
$env:JVM_OPTS="$env:JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.3.0.jar=7070:$PWD/cassandra.yml'"
I removed a single quote from the end of the line.
来源:https://stackoverflow.com/questions/65345430/unable-to-run-prometheus-on-windows-10-for-cassandra