[ 
https://issues.apache.org/jira/browse/SOLR-17436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18051108#comment-18051108
 ] 

Isabelle Giguere edited comment on SOLR-17436 at 1/11/26 4:37 PM:
------------------------------------------------------------------

So, to recap...

The V1 API "/admin/metrics" supports 2 'wt' : `prometheus` and `openmetrics` 

>From branch_10_0, and from branch main (11x) , both `prometheus` and 
>`openmetrics`  return a plain text response.  Example:
{noformat}
# TYPE solr_core_requests counter
# HELP solr_core_requests HTTP Solr requests
solr_core_requests_total{category="QUERY",collection="test",core="test_shard1_replica_n1",handler="/select",internal="false",otel_scope_name="org.apache.solr",replica_type="NRT",shard="shard1"}
 1.0
solr_core_requests_total{category="ADMIN",collection="test",core="test_shard1_replica_n1",handler="/config",otel_scope_name="org.apache.solr",replica_type="NRT",shard="shard1"}
 2.0 {noformat}

I am puzzled, at least, if not completely lost.

1. How does V1 return this plain text response?
MetricsHandler still seems to create a sort of Map or NamedList (key="metrics", 
value=MetricSnaphots), but the returned MediaType of the response is 
"text/plain".  The content writer assiociated with MetricsHandler appears to be 
JacksonJsonWriter, and I can't find where this would be set otherwise (i.e.: to 
a plain text writer).
Where is the plain text response writer set?  Or how does JacksonJsonWriter 
output plain text, magically, just for metrics?

2.  The JAX-RS API is bound to SolrJerseyResponse
If I add a JAX-RS API (MetricsApi), it's method (getMetrics()) must return a 
(extension of) SolrJerseyResponse.  This is somehow made mandatory by the 
Mustache generator in SolrJ, which re-creates a class named MetricsApi, that 
includes extra methods (from SolrRequest), one of which (getResponseParser()) 
tries to return a JacksonDatabindResponseParser.  This generated class fails to 
compile if "my" MetricsApi.getMetrics() returns a String or Object.
If "my" MetricsApi.getMetrics() returns a SolrJerseyResponse, it only shows 
some metadata (field names and descriptions) in Json format.  If the response 
is, say, MetricsResponse extends SolrJerseyResponse, with a field named 
"metrics", then the response shows a NamedList, but with the Prometehus class 
names instead of metrics:

{code:xml}
<arr 
name="metrics"><str>io.prometheus.metrics.model.snapshots.GaugeSnapshot@83275</str><!--
 ... --></arr>
{code}

In theory, Jersey resources should be able to return any MediaType (annotation 
@Produces).  But in Solr's JAX-RS, everything seems bound to 
SolrJerseyResponse.  Or I haven't found the spot where that could be set 
differently, at least for metrics.

3. Was this change wanted? [~mlbiscoc]
Solr 9.10 "/admin/metrics" returns metrics layed-out in a Json response.  Not 
plain text.
Solr 10x+ returns plain text, even if the MetricsHandler sets the data into key 
"metrics" (SolrQueryResponse "values")



was (Author: igiguere):
So, to recap...

The V1 API "/admin/metrics" supports 2 'wt' : `prometheus` and `openmetrics` 

>From branch_10_0, and from branch main (11x) , both `prometheus` and 
>`openmetrics`  return a plain text response.  Example:
{noformat}
# TYPE solr_core_requests counter
# HELP solr_core_requests HTTP Solr requests
solr_core_requests_total{category="QUERY",collection="test",core="test_shard1_replica_n1",handler="/select",internal="false",otel_scope_name="org.apache.solr",replica_type="NRT",shard="shard1"}
 1.0
solr_core_requests_total{category="ADMIN",collection="test",core="test_shard1_replica_n1",handler="/config",otel_scope_name="org.apache.solr",replica_type="NRT",shard="shard1"}
 2.0 {noformat}

I am puzzled, at least, if not completely lost.

1. How does V1 return this plain text response?
MetricsHandler still seems to create a sort of Map or NamedList (key="metrics", 
value=MetricSnaphots), but the returned MediaType of the response is 
"text/plain".  The content writer assiociated with MetricsHandler appears to be 
JacksonJsonWriter, and I can't find where this would be set otherwise (i.e.: to 
a plain text writer).

2.  The JAX-RS API is bound to SolrJerseyResponse
If I add a JAX-RS API (MetricsApi), it's method (getMetrics()) must return a 
(extension of) SolrJerseyResponse.  This is somehow made mandatory by the 
Mustache generator in SolrJ, which re-creates a class named MetricsApi, that 
includes extra methods (from SolrRequest), one of which (getResponseParser()) 
tries to return a JacksonDatabindResponseParser.  This generated class fails to 
compile if "my" MetricsApi.getMetrics() returns a String or Object.
If "my" MetricsApi.getMetrics() returns a SolrJerseyResponse, it only shows 
some metadata (field names and descriptions) in Json format.  If the response 
is, say, MetricsResponse extends SolrJerseyResponse, with a field named 
"metrics", then the response shows a NamedList, but with the Prometehus class 
names instead of metrics:

{code:xml}
<arr 
name="metrics"><str>io.prometheus.metrics.model.snapshots.GaugeSnapshot@83275</str><!--
 ... --></arr>
{code}

In theory, Jersey resources should be able to return any MediaType (annotation 
@Produces).  But in Solr's JAX-RS, everything seems bound to 
SolrJerseyResponse.  Or I haven't found the spot where that could be set 
differently, at least for metrics.

3. Was this change wanted? [~mlbiscoc]
Solr 9.10 "/admin/metrics" returns metrics layed-out in a Json response.  Not 
plain text.
Solr 10x+ returns plain text, even if the MetricsHandler sets the data into key 
"metrics" (SolrQueryResponse "values")
Where is the plain text response writer set?  Or how does JacksonJsonWriter 
output plain text, magically, just for metrics?

> Create a v2 equivalent for /admin/metrics
> -----------------------------------------
>
>                 Key: SOLR-17436
>                 URL: https://issues.apache.org/jira/browse/SOLR-17436
>             Project: Solr
>          Issue Type: Sub-task
>            Reporter: Matthew Biscocho
>            Priority: Major
>
> The /admin/metrics API has no equivalent in the v2 paradigm.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to