adamjq opened a new pull request, #3665:
URL: https://github.com/apache/solr/pull/3665

   https://issues.apache.org/jira/browse/SOLR-17806
   
   # Description
   
   Migrates DropWizard metrics for AuditLoggerPlugin to OpenTelemetry.
   
   See: 
https://solr.apache.org/guide/solr/latest/deployment-guide/audit-logging.html
   
   # Solution
   
   - Migrates AuditLoggerPlugin metrics to Open Telemetry format
   - Supports both async and non-async mode
   - Updates Solr docs with new metric names
   
   # Output
   
   The following output was tested manually with the following steps:
   
   1. Start Solr 
       e.g. ` ./solr/packaging/build/dev/bin/solr start -f`
   2. Upload a `security.json` config to Zookeeper to enable the 
AuditLoggerPlugin 
       e.g. `./solr/packaging/build/dev/bin/solr zk cp ./security.json 
zk:/security.json`
   3. Create a core
       e.g. `./solr/packaging/build/dev/bin/solr create -c test_core`
   
   Example Async config:
   ```json
   // security.json
   {
     "auditlogging": {
       "class": "solr.SolrLogAuditLoggerPlugin"
     }
   }
   ```
   
   Example non-async config:
   ```json
   // security.json
   {
     "auditlogging": {
       "class": "solr.SolrLogAuditLoggerPlugin",
      "async": false
     }
   }
   ```
   
   ## Dropwizard Metrics
   
   ### Sync mode (async=false)
   
   ```json
   "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.async":false,
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.count":{
           "count":6,
           "meanRate":0.3923022549607172,
           "1minRate":0.08827522768645096,
           "5minRate":0.019506424007533902,
           "15minRate":0.006611350453169309
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.errors":{
           "count":0,
           "meanRate":0.0,
           "1minRate":0.0,
           "5minRate":0.0,
           "15minRate":0.0
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.lost":{
           "count":0,
           "meanRate":0.0,
           "1minRate":0.0,
           "5minRate":0.0,
           "15minRate":0.0
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.requestTimes":{
           "count":6,
           "meanRate":0.39230042098166823,
           "1minRate":0.08827522768645096,
           "5minRate":0.019506424007533902,
           "15minRate":0.006611350453169309,
           "min_ms":0.031542,
           "max_ms":2.2115,
           "mean_ms":0.40006581990839635,
           "median_ms":0.0425,
           "stddev_ms":0.806469113833175,
           "p75_ms":0.050458,
           "p95_ms":2.2115,
           "p99_ms":2.2115,
           "p999_ms":2.2115
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.totalTime":2416499,
   ```
   
   ### Async mode
   ```json
   "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.async":true,
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.count":{
           "count":7,
           "meanRate":0.21123983604708124,
           "1minRate":0.10740483851948114,
           "5minRate":0.02292676949451791,
           "15minRate":0.007731861467774362
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.errors":{
           "count":0,
           "meanRate":0.0,
           "1minRate":0.0,
           "5minRate":0.0,
           "15minRate":0.0
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.lost":{
           "count":0,
           "meanRate":0.0,
           "1minRate":0.0,
           "5minRate":0.0,
           "15minRate":0.0
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.queueCapacity":4096,
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.queueSize":0,
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.queuedTime":{
           "count":7,
           "meanRate":0.21124007854388954,
           "1minRate":0.10740483851948114,
           "5minRate":0.02292676949451791,
           "15minRate":0.007731861467774362,
           "min_ms":0.0,
           "max_ms":3.0,
           "mean_ms":0.4855092884037528,
           "median_ms":0.0,
           "stddev_ms":0.958895062084824,
           "p75_ms":1.0,
           "p95_ms":3.0,
           "p99_ms":3.0,
           "p999_ms":3.0
         },
         "SECURITY./auditlogging.SolrLogAuditLoggerPlugin.requestTimes":{
           "count":7,
           "meanRate":0.21123863204315033,
           "1minRate":0.10740483851948114,
           "5minRate":0.02292676949451791,
           "15minRate":0.007731861467774362,
           "min_ms":0.033083,
           "max_ms":5.814917,
           "mean_ms":0.6863585464871763,
           "median_ms":0.042,
           "stddev_ms":1.8178587517257718,
           "p75_ms":0.059334,
           "p95_ms":5.814917,
           "p99_ms":5.814917,
           "p999_ms":5.814917
         },
   ```
   
   ## Open Telemetry Metrics
   
   ### Sync mode (async=false)
   
   ```bash
   # HELP solr_auditlogger_async_enabled Whether the audit logger is running in 
async mode (1) or not (0)
   # TYPE solr_auditlogger_async_enabled gauge
   
solr_auditlogger_async_enabled{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 0.0
   # HELP solr_auditlogger_count_total The number of audit events that were 
successfully logged.
   # TYPE solr_auditlogger_count_total counter
   
solr_auditlogger_count_total{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 7.0
   # HELP solr_auditlogger_request_times_nanoseconds Distribution of 
authentication request durations
   # TYPE solr_auditlogger_request_times_nanoseconds histogram
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="0.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="25.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="50.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="75.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="100.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="250.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="500.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="750.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="1000.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="2500.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5000.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="7500.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10000.0"}
 7
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="+Inf"}
 7
   
solr_auditlogger_request_times_nanoseconds_count{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 7
   
solr_auditlogger_request_times_nanoseconds_sum{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 1.0
   ```
   
   ### Async mode
   
   ```bash
   # HELP solr_auditlogger_async_enabled Whether the audit logger is running in 
async mode (1) or not (0)
   # TYPE solr_auditlogger_async_enabled gauge
   
solr_auditlogger_async_enabled{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 1.0
   # HELP solr_auditlogger_count_total The number of audit events that were 
successfully logged.
   # TYPE solr_auditlogger_count_total counter
   
solr_auditlogger_count_total{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 6.0
   # HELP solr_auditlogger_queue Metrics around the audit logger queue when 
running in async mode
   # TYPE solr_auditlogger_queue gauge
   
solr_auditlogger_queue{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",type="capacity"}
 4096.0
   
solr_auditlogger_queue{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",type="size"}
 0.0
   # HELP solr_auditlogger_queued_time_nanoseconds Distribution of time events 
spend queued before processing
   # TYPE solr_auditlogger_queued_time_nanoseconds histogram
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="0.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="25.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="50.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="75.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="100.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="250.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="500.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="750.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="1000.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="2500.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5000.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="7500.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10000.0"}
 5
   
solr_auditlogger_queued_time_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="+Inf"}
 6
   
solr_auditlogger_queued_time_nanoseconds_count{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 6
   
solr_auditlogger_queued_time_nanoseconds_sum{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 1000000.0
   # HELP solr_auditlogger_request_times_nanoseconds Distribution of 
authentication request durations
   # TYPE solr_auditlogger_request_times_nanoseconds histogram
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="0.0"}
 5
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="25.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="50.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="75.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="100.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="250.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="500.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="750.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="1000.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="2500.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="5000.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="7500.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="10000.0"}
 6
   
solr_auditlogger_request_times_nanoseconds_bucket{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin",le="+Inf"}
 6
   
solr_auditlogger_request_times_nanoseconds_count{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 6
   
solr_auditlogger_request_times_nanoseconds_sum{category="SECURITY",handler="/auditlogging",otel_scope_name="org.apache.solr",plugin_name="SolrLogAuditLoggerPlugin"}
 2.0
   ```
   
   # Tests
   
   Updates existing unit and integration tests and manually tested the change.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [X] I have reviewed the guidelines for [How to 
Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my 
code conforms to the standards described there to the best of my ability.
   - [X] I have created a Jira issue and added the issue ID to my pull request 
title.
   - [X] I have given Solr maintainers 
[access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
 to contribute to my PR branch. (optional but recommended, not available for 
branches on forks living under an organisation)
   - [ ] I have developed this patch against the `main` branch.
   - [X] I have run `./gradlew check`.
   - [X] I have added tests for my changes.
   - [X] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to