I am using com.sparkjava library for writing API.I want to monitor the metrics of these API like the average ,min and max time taken to give the response, throughput for the API's and count of request sent for the API etc.,
I was looking for a suitable library which provides all these data.I want these metrics data to be registered in the JVM using the JMX technology.I know of codahale.metrics library for registering ,apart from that are there any other better libraries?I don't want to write the MBean objects and register in the MBeanRegisrty unless there is no other alternative.I am looking for a library which gives the above metrics data once i run the application.
Have you tried newrelic? It's very easy to set up and gives you a lot of data out of the box :)
Related
I was wondering if it is possible to collect all metric from Prometheus with Java client?
For example Go metrics, host metrics etc.
If yes, can these metrics be queried like on HTTP api?
Could you please clarify: "instrumenting" usually means exposing metrics from your application's code to a Prometheus endpoint. The question reads that you either want to read metrics from an application, or from a Prometheus instance that has already scraped the metrics.
For this answer I assume that you're running a Prometheus instance that has already scraped the metrics.
If you want to read the most current values that Prometheus has scraped from your applications, you can use Prometheus' federation endpoint via HTTP: you can read all metrics with their current readings in one go, or apply a query. I'm not aware of a Java library to parse the format, but you find the definition here. You could use the same approach to query your applications directly.
If you want to receive a JSON that might be easier to parse, you can use Prometheus's HTTP API.
If you want to receive updates on values as soon as Prometheus queries them, you can hook up to the remote write API. There is already existing integrations, but at first glance there is no Java integration. You could use Kafka as an intermediary. Also, this might be more than you've asked for in this questions.
I want to fetch various metrics like read/write latency, disk utilisation etc. of each of my Cassandra nodes(without using JMX) as a JSON object. It seems to me that MetricsServlet, can do exactly that. However, I'm still not able to figure out, what all do I need to do in order to use it(metrics-servlets does not come with Cassandra). I'll appreciate if I can get some advice/sample code(for fetching any metric).
Cassandra is not a java web server, it doesnt support servlets. You would need to start a java web server in same JVM as Cassandra and load those servlets. While possible its probably a lot less work to just query the metrics via JMX and convert to JSON with an external application or to expose JMX via http with something like MX4J (what I would recommend)
I would like to gather and store data on the availability of the service or node. The day after I could summarize the figures, like { day-1: service = 98.5%; day-2 = 99%}.
I could get the data by calling a simple rest (ping) service (e.g. via Actuator or what). Then I would need to write a custom scheduled application calling the Actuator/ping services.
Is there a simple solution for collecting/storing the availability data? Via Spring Batch?
UPDATE 31-05: I read about Spring Boot Admin. Is this the right solution? See also this introduction.
The data could be extracted and formatted in a CSV, JasperReporting, etc.
I hope that I can help you. I think that what you need is a way of monitoring your applications in a persistent way. You can build your own solution creating a Ping resource and scheduling a client to collect availability information from time to time. But, to no re-invent the wheel, a really suggest you use some professional tool.
I recommend that you use a Dashboard tool like Grafana to create these reports, and I suggest you try Prometheus to capture monitoring pieces of information.
I have listed some links below.
Actuator and Prometheus
monitoring-spring-boot-applications-with-prometheus
Prometheus dashboard in Grafana
My application sends http requests to a webservice, but because the Terms of Service limit it to one query per second it is very important for me not to send more queries than I need. I put the results of some queries into a database that I check before trying the query again but some queries results are not well suited to putting in database so I would like some sort of dumb cache that would intercept my webservice calls and if the call was a duplicate just send the results of the previous call. I would expect to be able to configure the size of the cache and have it automatically remove the oldest entry if it fills up, it would be great if the cache could be configured as a file rather than use heap memory because my application is already quite memory intensive
For a simple caching solution try Google Guava libraries. The CacheBuilder/CacheLoader could be configured to your requirements. Guava provides a simple caching solution that is more sofisticated than java's own HashMap but light weight when compared to Ehcache and others. This cache could be used in a web service request interceptor that helps to decide whether to initiate a web service call.
A good tutorial with an example for Guava cache could be found here
Certain real-time features of the server application I'm working on would benefit from exposing counters to a Network Management System.
I am thinking about a solution where I am using the JMX API from a Java application and via some configuration/magic/libraries can expose this information as SNMP data.
Back in the old days, JDMK did something like this I quess. Is that still the best solution? Was there some issues regarding the license of JDMK?
What about MX4J, can it be used to export counters via SNMP?
Other, better solutions?