SOLR-13286 Quiet down metrics logging, add a marker to allow any handler to be silenced via log4j2.xml

This commit is contained in:
Gus Heck 2020-06-26 18:00:52 -04:00
parent 68a9e8fc97
commit 455f2e6c73
3 changed files with 18 additions and 7 deletions

View File

@ -25,6 +25,9 @@ Improvements
* SOLR-14387: SolrClient.getById() will escape comma separater within ids (Markus Schuch via Mike Drob)
* SOLR-13286: Metrics will no longer write a (sometimes large) log message every minute. This can be re-enabled
via log4j2.xml if desired, or other HttpSolrCall log messages may be quieted on a per handler basis. (Gus Heck)
Other Changes
----------------------
* LUCENE-9391: Upgrade HPPC to 0.8.2. (Haoyu Zhai)

View File

@ -113,6 +113,7 @@ import org.apache.solr.util.tracing.GlobalTracer;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
@ -473,7 +474,7 @@ public class HttpSolrCall {
log.debug("AuthorizationContext : {}", context);
AuthorizationResponse authResponse = cores.getAuthorizationPlugin().authorize(context);
int statusCode = authResponse.statusCode;
if (statusCode == AuthorizationResponse.PROMPT.statusCode) {
@SuppressWarnings({"unchecked"})
Map<String, String> headers = (Map) getReq().getAttribute(AuthenticationPlugin.class.getName());
@ -637,7 +638,7 @@ public class HttpSolrCall {
private boolean shouldAuthorize() {
if(PublicKeyHandler.PATH.equals(path)) return false;
//admin/info/key is the path where public key is exposed . it is always unsecured
if ("/".equals(path) || "/solr/".equals(path)) return false; // Static Admin UI files must always be served
if ("/".equals(path) || "/solr/".equals(path)) return false; // Static Admin UI files must always be served
if (cores.getPkiAuthenticationPlugin() != null && req.getUserPrincipal() != null) {
boolean b = cores.getPkiAuthenticationPlugin().needsAuthorization(req);
log.debug("PkiAuthenticationPlugin says authorization required : {} ", b);
@ -816,8 +817,10 @@ public class HttpSolrCall {
SolrCore.preDecorateResponse(solrReq, solrResp);
handleAdmin(solrResp);
SolrCore.postDecorateResponse(handler, solrReq, solrResp);
if (log.isInfoEnabled() && solrResp.getToLog().size() > 0) {
log.info(solrResp.getToLogAsString("[admin]"));
if (solrResp.getToLog().size() > 0) {
if (log.isInfoEnabled()) { // has to come second and in it's own if to keep ./gradlew check happy.
log.info(handler != null ? MarkerFactory.getMarker(handler.getClass().getName()) : MarkerFactory.getMarker(HttpSolrCall.class.getName()), solrResp.getToLogAsString("[admin]"));
}
}
QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT));
if (respWriter == null) respWriter = getResponseWriter();
@ -1134,7 +1137,7 @@ public class HttpSolrCall {
public String getHttpHeader(String s) {
return getReq().getHeader(s);
}
@Override
public Enumeration<String> getHeaderNames() {
return getReq().getHeaderNames();
@ -1149,7 +1152,7 @@ public class HttpSolrCall {
public RequestType getRequestType() {
return requestType;
}
public String getResource() {
return path;
}
@ -1173,7 +1176,7 @@ public class HttpSolrCall {
}
if(collectionRequests.size() > 0)
response.delete(response.length() - 1, response.length());
response.append("], Path: [").append(resource).append("]");
response.append(" path : ").append(path).append(" params :").append(getParams());
return response.toString();

View File

@ -66,6 +66,11 @@
<AsyncLogger name="org.apache.hadoop" level="warn"/>
<AsyncLogger name="org.apache.solr.update.LoggingInfoStream" level="off"/>
<AsyncLogger name="org.apache.zookeeper" level="warn"/>
<!-- HttpSolrCall adds markers denoting the handler class to allow fine grained control, metrics are
very noisy so by default the metrics handler is turned off to see metrics logging set DENY to ACCEPT -->
<AsyncLogger name="org.apache.solr.servlet.HttpSolrCall" level="info">
<MarkerFilter marker="org.apache.solr.handler.admin.MetricsHandler" onMatch="DENY" onMismatch="ACCEPT"/>
</AsyncLogger>
<AsyncLogger name="org.apache.solr.core.SolrCore.SlowRequest" level="info" additivity="false">
<AppenderRef ref="SlowLogFile"/>
</AsyncLogger>