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

Add metadata fields to elastic adapter #121

Merged

Conversation

JSCU-CNI
Copy link
Contributor

@JSCU-CNI JSCU-CNI commented Apr 24, 2024

This PR adds metadata fields to the elastic adapter and repairs elastic+[PROTOCOL]:// behaviour. It also enables users to authenticate to Elasticsearch with an API key.

You can now write arbitrary metadata to the document._source._record_metadata dict using the following syntax:

rdump -w "elastic+https://localhost:9200?_meta_foo=bar"

This will result in the following _record_metadata dict:

{
    ...
    "foo": "bar"
}

Of course we can change _meta_ to something else if that seems more appropriate for the flow.record project.

@JSCU-CNI JSCU-CNI force-pushed the improvement/elastic-adapter-metadata-fields branch from 307200b to fff4519 Compare April 24, 2024 15:27
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 83.67%. Comparing base (e0586ef) to head (cd99f9b).

Files Patch % Lines
flow/record/adapter/elastic.py 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   81.94%   83.67%   +1.72%     
==========================================
  Files          34       34              
  Lines        3385     3394       +9     
==========================================
+ Hits         2774     2840      +66     
+ Misses        611      554      -57     
Flag Coverage Δ
unittests 83.67% <76.92%> (+1.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
Copy link
Member

@yunzheng yunzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed some small inconsistencies for the http:// prefixing. See code suggestions.

After this it should be good to merge!

flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
flow/record/adapter/elastic.py Outdated Show resolved Hide resolved
@yunzheng yunzheng merged commit 43a5656 into fox-it:main May 15, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants