Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Lucene observability #3535

Merged
merged 3 commits into from
Apr 16, 2024
Merged

Conversation

nscuro
Copy link
Member

@nscuro nscuro commented Mar 10, 2024

Description

Collect basic metrics:

  • Total number of index operations (add, update, delete, commit), grouped by index
  • Number of index documents in RAM
  • Number of bytes used by the index
  • Total number of documents in the index

Also, integrate Lucene's InfoStream with Dependency-Track's logging system. Lucene output will now be included when configuring LOGGING_LEVEL=DEBUG, or when the respective logger is explicitly configured in logback.xml.

Addressed Issue

Relates to #3429

Additional Details

Logging of Lucene messages can be enabled on a per-index basis:

<!-- logback.xml -->
<logger name="org.dependencytrack.search.VulnerabilityIndexer.lucene" level="DEBUG" additivity="false">
  <appender-ref ref="STDOUT"/>
</logger>

It is also possible to enable logging selectively for specific Lucene components (e.g. for IndexWriter IW):

<!-- logback.xml -->
<logger name="org.dependencytrack.search.VulnerabilityIndexer.lucene.IW" level="DEBUG" additivity="false">
  <appender-ref ref="STDOUT"/>
</logger>

Newly exposed metrics:

# HELP search_index_docs_total_objects Number of docs in this index, including docs not yet flushed (still in the RAM buffer), and including deletions
# TYPE search_index_docs_total_objects gauge
search_index_docs_total_objects{index="VULNERABILITY",} 249586.0

# HELP search_index_operations_total Total number of index operations
# TYPE search_index_operations_total counter
search_index_operations_total{index="VULNERABILITY",operation="commit",} 7.0
search_index_operations_total{index="VULNERABILITY",operation="delete",} 0.0
search_index_operations_total{index="VULNERABILITY",operation="add",} 0.0
search_index_operations_total{index="VULNERABILITY",operation="update",} 139857.0

# HELP search_index_ram_bytes_used_total_bytes Memory usage of the index in bytes
# TYPE search_index_ram_bytes_used_total_bytes gauge
search_index_ram_bytes_used_total_bytes{index="VULNERABILITY",} 7279344.0

# HELP search_index_docs_ram_total_objects Number of documents currently buffered in RAM
# TYPE search_index_docs_ram_total_objects gauge
search_index_docs_ram_total_objects{index="VULNERABILITY",} 8646.0

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

@nscuro nscuro added the enhancement New feature or request label Mar 10, 2024
@nscuro nscuro added this to the 4.11 milestone Mar 10, 2024
Copy link

codacy-production bot commented Mar 10, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.25% (target: -1.00%) 57.89% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8c9a74a) 21953 16379 74.61%
Head commit (5885940) 21967 (+14) 16445 (+66) 74.86% (+0.25%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3535) 228 132 57.89%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Collect basic metrics:

* Total number of index operations (`add`, `update`, `delete`, `commit`), grouped by index
* Number of index documents in RAM
* Number of bytes used by the index
* Total number of documents in the index

Also, integrate Lucene's `InfoStream` with Dependency-Track's logging system. Lucene output will now be included when configuring `LOGGING_LEVEL=DEBUG`, or when the respective logger is explicitly configured in `logback.xml`.

Relates to DependencyTrack#3429

Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Their `close` method is a no-op.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro marked this pull request as ready for review April 16, 2024 19:59
@nscuro nscuro merged commit 6583e2d into DependencyTrack:master Apr 16, 2024
10 of 12 checks passed
@nscuro nscuro deleted the issue-3429 branch April 16, 2024 21:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant