Hi Deniz,

I don't think there are any classes that simplify accessing the
metrics API like there are for other APIs (e.g.
CollectionAdminRequest, CoreAdminRequest, ..).  But sending metrics
requests in SolrJ is still possible; it's just a little bit more
complicated.

Anytime you want to make an API call that doesn't have specific
objects for it, you can use one of the general-purpose SolrRequest
objects.  I've included an example below that reads the
"classes.loaded" JVM metric:

        final SolrClient client = new
HttpSolrClient.Builder("http://localhost:8983/solr";).build();

        final ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("group", "jvm");
        final GenericSolrRequest req = new
GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/metrics", params);

        SimpleSolrResponse response = req.process(client);
        NamedList<Object> respNL = response.getResponse();
        NamedList<Object> metrics = (NamedList<Object>)respNL.get("metrics");
        NamedList<Object> jvmMetrics = (NamedList<Object>)
metrics.get("solr.jvm");
        Long numClassesLoaded = (Long) jvmMetrics.get("classes.loaded");
        System.out.println("Num classes loaded was: " + numClassesLoaded);

It's a little more painful to have to dig through the NamedList
yourself, but it's still very do-able.  Hope that helps.

Best,

Jason
On Wed, Oct 3, 2018 at 3:03 AM deniz <denizdurmu...@gmail.com> wrote:
>
> Are there anyway to get the metrics via solrj ? all of the examples seem like
> using plain curl or http reqs with json response. I have found
> org.apache.solr.client.solrj.io.stream.metrics package, but couldnt figure
> out how to send the requests via solrj...
>
> could anyone help me to figure out how to deal with metrics api on solrj?
>
>
>
> -----
> Zeki ama calismiyor... Calissa yapar...
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Reply via email to