-
Notifications
You must be signed in to change notification settings - Fork 341
feat: add query() time_unit option, list_streams(), list_alerts(), docs fix #937
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
Open
Julien (juju4)
wants to merge
10
commits into
microsoft:main
Choose a base branch
from
juju4:devel-openobserve2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d08b5d0
feat: add query() time_unit option, list_streams(), list_alerts()
juju4 c3d8e82
docs: fix OpenObserve example notebook
juju4 4f14899
docs: add OpenObserve provider
juju4 751bf2e
Merge branch 'main' into devel-openobserve2
ianhelle 993788f
Merge branch 'main' into devel-openobserve2
juju4 e5f5097
fix: add/restore _ensure_connected()
juju4 630287f
docs: fix code examples
juju4 208dc95
docs: fix openobserve notebook - WIP: line 91 has source
juju4 b17fc08
docs: remove non-existing sphinx ref
juju4 e654506
docs: fix openobserve notebook (2)
juju4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| OpenObserve Provider | ||
| ================== | ||
|
|
||
| OpenObserve Configuration | ||
| ----------------------- | ||
|
|
||
| You can store your connection details in *msticpyconfig.yaml*. | ||
|
|
||
| For more information on using and configuring *msticpyconfig.yaml* see | ||
| :doc:`msticpy Package Configuration <../getting_started/msticpyconfig>` | ||
| and :doc:`MSTICPy Settings Editor<../getting_started/SettingsEditor>` | ||
|
|
||
| The settings in the file should look like the following: | ||
|
|
||
| .. code:: yaml | ||
|
|
||
| DataProviders: | ||
| OpenObserve: | ||
| Args: | ||
| connection_str: openobserve_url | ||
| user: | ||
| password: | ||
|
|
||
| We strongly recommend storing the password value | ||
| in Azure Key Vault. You can replace the text value with a referenced | ||
| to a Key Vault secret using the MSTICPy configuration editor. | ||
|
|
||
| Your configuration when using Key Vault should look like the following: | ||
|
|
||
| .. code:: yaml | ||
|
|
||
| DataProviders: | ||
| OpenObserve: | ||
| Args: | ||
| connection_str: openobserve_url | ||
| user: | ||
| password: | ||
| KeyVault: | ||
|
|
||
| Loading a QueryProvider for OpenObserve | ||
| ------------------------------------------- | ||
|
|
||
| .. code:: ipython3 | ||
|
|
||
| qry_prov = QueryProvider("OpenObserve") | ||
|
|
||
|
|
||
| Connecting to OpenObserve | ||
| ----------------------------- | ||
|
|
||
| The parameters required for connection to OpenObserve can be passed in | ||
| a number of ways. The simplest is to configure your settings | ||
| in msticpyconfig. You can then just call connect with no parameters. | ||
|
|
||
| Alternatively, you can pass the required connection parameters | ||
| to the driver as parameters to the driver. | ||
|
|
||
| .. code:: ipython3 | ||
|
|
||
| qry_prov.connect() | ||
|
|
||
|
|
||
| If you have configured multiple instances you must specify | ||
| an instance name when you call connect. | ||
|
|
||
| .. code:: ipython3 | ||
|
|
||
| qry_prov.connect(instance="Instance2") | ||
|
|
||
| Running a OpenObserve query | ||
| ------------------------- | ||
|
|
||
| OpenObserve supports a number of optional query time parameters. | ||
| Details of those parameters can be found here | ||
| :py:meth:`msticpy.data.drivers.openobserve_driver.query` | ||
|
|
||
| Be mindful that there is no standard schema by default in openobserve | ||
| and streams (aka table) naming is depending on setup choice. | ||
| Review corresponding streams before digging further. | ||
| Also know, that by default only a _timestamp field matching ingestion | ||
| or received time exists. the logs or message time must be extracted | ||
| through pipelines. | ||
|
|
||
| .. code:: ipython3 | ||
|
|
||
| df_streams = qry_prov.list_streams() | ||
| df_streams[df_streams['stream_type'] == 'logs'][['name']].head() | ||
|
|
||
| query = """SELECT host_name as "host_name", | ||
| min(_timestamp) as "firstseen", | ||
| max(_timestamp) as "lastseen", | ||
| count() as "count" | ||
| FROM "journald" GROUP BY host_name | ||
| """ | ||
| df = qry_prov.exec_query(query, days=1, verbosity=3) | ||
| df.head() | ||
|
|
||
| .. code:: ipython3 | ||
|
|
||
| query = """SELECT...""" | ||
| df = qry_prov.exec_query( | ||
| query, | ||
| start=datetime.now() - timedelta(days=6.001), | ||
| end=datetime.now() - timedelta(days=6) | ||
| ) | ||
| df.head() | ||
|
|
||
| Other OpenObserve Documentation | ||
| ----------------------------- | ||
|
|
||
| For examples of using the OpenObserve provider, see the sample | ||
| `OpenObserve Notebook <https://github.com/microsoft/msticpy/blob/main/docs/notebooks/OpenObserve-DataConnector.ipynb>` | ||
|
|
||
| :py:mod:`OpenObserve driver API documentation<msticpy.data.drivers.openobserve_driver>` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.