[ 
https://issues.apache.org/jira/browse/SOLR-17638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17931494#comment-17931494
 ] 
Alex Deparvu edited comment on SOLR-17638 at 2/28/25 2:56 PM:
--------------------------------------------------------------

I am able to reproduce this and I think it might be related to the `exec` 
command somehow not being able to deal with the stacktrace being included in 
the output.

This is the current code that breaks output - and aparently any logs coming to 
the cli after this messsage:
{code:java}
log.error("Failed to parse command line arguments: ", e);
{code}
A simple change fixes this. downside is for the ParseException this is 
sufficient but in the generic exception case it is not ideal to not have the 
stacktrace.
{code:java}
log.error("Failed to parse command line arguments: {}", e.getMessage());
{code}
I think a better fix could be in the exec script itself, but don't know yet.

 

I can't tell if this is a widerspread cli issue of just affecting this module 
only. [~epugh] any ideas?

 

Note. there is also a `return` statement [missing 
here|https://github.com/apache/solr/blob/releases/solr/9.8.0/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java#L366]
 causing the NPE in the cli output which should be fixed.
{code:java}
Exception in thread "main" java.lang.NullPointerException: Cannot invoke 
"org.apache.solr.prometheus.exporter.SolrScrapeConfiguration.getType()" because 
"configuration" is null
{code}
 


was (Author: alex.parvulescu):
I am able to reproduce this and I think it might be related to the `exec` 
command somehow not being able to deal with the stacktrace being included in 
the output.

This is the current code that breaks output - and aparently any logs coming to 
the cli after this messsage:
{code:java}
log.error("Failed to parse command line arguments: ", e);
{code}
A simple change fixes this. downside is for the ParseException this is 
sufficient but in the generic exception case it is not ideal to not have the 
stacktrace.
{code:java}
log.error("Failed to parse command line arguments: {}", e.getMessage());
{code}
I think a better fix could be in the exec script itself, but don't know yet. I 
can't tell if this is a widerspread cli issue of just affecting this module 
only. [~epugh] any ideas?


Note. there is also a `return` statement [missing 
here|https://github.com/apache/solr/blob/releases/solr/9.8.0/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java#L366]
 causing the NPE in the cli output which should be fixed.
{code}
Exception in thread "main" java.lang.NullPointerException: Cannot invoke 
"org.apache.solr.prometheus.exporter.SolrScrapeConfiguration.getType()" because 
"configuration" is null
{code}
 

> Some CLI errors not logged when starting prometheus exporter
> ------------------------------------------------------------
>
>                 Key: SOLR-17638
>                 URL: https://issues.apache.org/jira/browse/SOLR-17638
>             Project: Solr
>          Issue Type: Bug
>          Components: contrib - prometheus-exporter
>    Affects Versions: 9.8
>            Reporter: Philipp Trulson
>            Priority: Major
>
> Hey everyone, we are currently upgrading our 8.11 setup to 9.8 and right now 
> I'm working on the prometheus-exporter.
> To my surprise, the program was exiting directly without any output at all, 
> which was very frustrating. Only after manually putting a log4j2 config in 
> the classpath the culprit was finally visible:
>  
> {noformat}
> org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: 
> --zkhost{noformat}
>  
> So the program was exiting because the cli option was renamed from zkhost to 
> zk-host, would have been an easy fix normally, _if_ the program would have 
> told me. What's funny though is that other messages are being logged to the 
> console and I can't find the difference atm. My guess is that something got 
> messed up after switching the cli lib in SOLR-16996.
> Reproduction:
> {code:java}
> $ podman run --rm -it --entrypoint bash solr:9.8.0 
> /opt/solr/prometheus-exporter/bin/solr-exporter --port=9854
> ERROR - 2025-01-30 08:52:53.052; 
> org.apache.solr.prometheus.exporter.SolrExporter; Must provide either 
> --base-url or --zk-host
> Exception in thread "main" java.lang.NullPointerException: Cannot invoke 
> "org.apache.solr.prometheus.exporter.SolrScrapeConfiguration.getType()" 
> because "configuration" is null
>     at 
> org.apache.solr.prometheus.exporter.SolrExporter.createScraper(SolrExporter.java:127)
>     at 
> org.apache.solr.prometheus.exporter.SolrExporter.<init>(SolrExporter.java:90)
>     at 
> org.apache.solr.prometheus.exporter.SolrExporter.main(SolrExporter.java:426)
> $ podman run --rm -it --entrypoint bash solr:9.8.0 
> /opt/solr/prometheus-exporter/bin/solr-exporter --zkhost=lalala
>   -> no output{code}
>  
> (Small sidenote: The program errors when not providing --base-url or 
> --zk-host, even though the help text says {_}If omitted both the -b parameter 
> and the -z parameter, connect to http://localhost:8983/solr{_}. Not sure if 
> it's worth opening a separate issue for that, looks like the CLI args are 
> being worked on already in 9.9)



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to