dqlmagic


Namedqlmagic JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/dtPaTh/Dqlmagic
SummaryIPython magic function for Dynatrace Query Language (DQL)
upload_time2024-06-28 12:10:40
maintainerNone
docs_urlNone
authorPatrick Thurner
requires_pythonNone
licenseApache 2.0
keywords notebook jupyter dql dynatrace query language
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dqlmagic

An IPython magic function allowing to use DQL in your notebooks.

Dynatrace Query Language (DQL) is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more based on data stored in Dynatrace Grail storage. 

Dqlmagic makes DQL queries available to be used in jupyter notebooks.

## Available magic functions

### %%dql or %dql
Executes a DQL query and returns the queried records as json array.

### Example 1
Query in code-cell..
```
%%dql
fetch logs 
| limit 10
```
.. and use result in another code cell:
```
import pandas as pd

#put result into a dataframe
df = pd.DataFrame(_dql_result)
df.head()
```
**Note:** 
By default ``%%dql`` writes into ``_dql_result``. You can optionally customize the target objects name to configure an alternative name like this: 
```
%%dql my_result
fetch logs | limit 10
```

### Example 2 - Inline Query
```
import pandas as pd

res = %dql fetch logs | limit 10
df = pd.DataFrame(res)
df.head()
```

### %dql_raw and %%dql_raw
Same as ```%dql``` or ```%%dql```, but returns instead of the result records the full API response json

### %auth_grail <config_prefix>
Inline function connecting to the grail cluster. 

Reads connection parameters from .env file: 
```
dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"

dt_oauth_clientid="<YOUR-CLIENT-ID>"
dt_oauth_clientsecret="<YOUR-CLIENT-SECRET>"
dt_oauth_scope="<YOUR-ACCESS-SCOPE>"

dt_tenant="<YOUR-TENANT-ID>"
grail_apiurl="https://<YOUR-TENANT-ID>.live.dynatrace.com/api/v2/dql/query"
```

The ```<config_prefix>``` is **optional** to be used if you have multiple configs stored in your .env file like e.g. 

```
dt_config_prefix="DEV"

DEV_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
DEV_dt_oauth_clientid="<YOUR-DEV-CLIENT-ID>"
DEV_dt_oauth_clientsecret="<YOUR-DEV-CLIENT-SECRET>"
DEV_dt_oauth_scope="<YOUR-DEV-ACCESS-SCOPE>"
DEV_dt_tenant="<YOUR-DEV-TENANT-ID>"
DEV_grail_apiurl="https://<YOUR-DEV-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"

PROD_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
PROD_dt_oauth_clientid="<YOUR-PROD-CLIENT-ID>"
PROD_dt_oauth_clientsecret="<YOUR-PROD-CLIENT-SECRET>"
PROD_dt_oauth_scope="<YOUR-PROD-ACCESS-SCOPE>"
PROD_dt_tenant="<YOUR-PROD-TENANT-ID>"
PROD_grail_apiurl="https://<YOUR-PROD-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"

```

With the parameter ```dt_config_prefix```, you set the default config prefix used, if %auth_grail parameter ```<config_prefix>``` is not provided.

For more details on how to setup API oauth clients in Dynatrace see [Configure and manage account API OAuth clients
](https://www.dynatrace.com/support/help/how-to-use-dynatrace/account-management/identity-access-management/account-api-oauth)

For more details on .env file see [How to NOT embedded credential in Jupyter notebook](https://yuthakarn.medium.com/how-to-not-show-credential-in-jupyter-notebook-c349f9278466) or [python-dotenv](https://pypi.org/project/python-dotenv/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dtPaTh/Dqlmagic",
    "name": "dqlmagic",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Notebook, Jupyter, DQL, Dynatrace Query Language",
    "author": "Patrick Thurner",
    "author_email": "patrick.thurner@dynatrace.com",
    "download_url": "https://files.pythonhosted.org/packages/88/06/e1e621b3eaf2aab87b06fc2868ef581ef9d369e4353d733938d38c96475c/dqlmagic-1.3.1.tar.gz",
    "platform": null,
    "description": "# Dqlmagic\r\n\r\nAn IPython magic function allowing to use DQL in your notebooks.\r\n\r\nDynatrace Query Language (DQL) is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more based on data stored in Dynatrace Grail storage. \r\n\r\nDqlmagic makes DQL queries available to be used in jupyter notebooks.\r\n\r\n## Available magic functions\r\n\r\n### %%dql or %dql\r\nExecutes a DQL query and returns the queried records as json array.\r\n\r\n### Example 1\r\nQuery in code-cell..\r\n```\r\n%%dql\r\nfetch logs \r\n| limit 10\r\n```\r\n.. and use result in another code cell:\r\n```\r\nimport pandas as pd\r\n\r\n#put result into a dataframe\r\ndf = pd.DataFrame(_dql_result)\r\ndf.head()\r\n```\r\n**Note:** \r\nBy default ``%%dql`` writes into ``_dql_result``. You can optionally customize the target objects name to configure an alternative name like this: \r\n```\r\n%%dql my_result\r\nfetch logs | limit 10\r\n```\r\n\r\n### Example 2 - Inline Query\r\n```\r\nimport pandas as pd\r\n\r\nres = %dql fetch logs | limit 10\r\ndf = pd.DataFrame(res)\r\ndf.head()\r\n```\r\n\r\n### %dql_raw and %%dql_raw\r\nSame as ```%dql``` or ```%%dql```, but returns instead of the result records the full API response json\r\n\r\n### %auth_grail <config_prefix>\r\nInline function connecting to the grail cluster. \r\n\r\nReads connection parameters from .env file: \r\n```\r\ndt_oauth_url=\"https://sso.dynatrace.com/sso/oauth2/token\"\r\n\r\ndt_oauth_clientid=\"<YOUR-CLIENT-ID>\"\r\ndt_oauth_clientsecret=\"<YOUR-CLIENT-SECRET>\"\r\ndt_oauth_scope=\"<YOUR-ACCESS-SCOPE>\"\r\n\r\ndt_tenant=\"<YOUR-TENANT-ID>\"\r\ngrail_apiurl=\"https://<YOUR-TENANT-ID>.live.dynatrace.com/api/v2/dql/query\"\r\n```\r\n\r\nThe ```<config_prefix>``` is **optional** to be used if you have multiple configs stored in your .env file like e.g. \r\n\r\n```\r\ndt_config_prefix=\"DEV\"\r\n\r\nDEV_dt_oauth_url=\"https://sso.dynatrace.com/sso/oauth2/token\"\r\nDEV_dt_oauth_clientid=\"<YOUR-DEV-CLIENT-ID>\"\r\nDEV_dt_oauth_clientsecret=\"<YOUR-DEV-CLIENT-SECRET>\"\r\nDEV_dt_oauth_scope=\"<YOUR-DEV-ACCESS-SCOPE>\"\r\nDEV_dt_tenant=\"<YOUR-DEV-TENANT-ID>\"\r\nDEV_grail_apiurl=\"https://<YOUR-DEV-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/\"\r\n\r\nPROD_dt_oauth_url=\"https://sso.dynatrace.com/sso/oauth2/token\"\r\nPROD_dt_oauth_clientid=\"<YOUR-PROD-CLIENT-ID>\"\r\nPROD_dt_oauth_clientsecret=\"<YOUR-PROD-CLIENT-SECRET>\"\r\nPROD_dt_oauth_scope=\"<YOUR-PROD-ACCESS-SCOPE>\"\r\nPROD_dt_tenant=\"<YOUR-PROD-TENANT-ID>\"\r\nPROD_grail_apiurl=\"https://<YOUR-PROD-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/\"\r\n\r\n```\r\n\r\nWith the parameter ```dt_config_prefix```, you set the default config prefix used, if %auth_grail parameter ```<config_prefix>``` is not provided.\r\n\r\nFor more details on how to setup API oauth clients in Dynatrace see [Configure and manage account API OAuth clients\r\n](https://www.dynatrace.com/support/help/how-to-use-dynatrace/account-management/identity-access-management/account-api-oauth)\r\n\r\nFor more details on .env file see [How to NOT embedded credential in Jupyter notebook](https://yuthakarn.medium.com/how-to-not-show-credential-in-jupyter-notebook-c349f9278466) or [python-dotenv](https://pypi.org/project/python-dotenv/)\r\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "IPython magic function for Dynatrace Query Language (DQL)",
    "version": "1.3.1",
    "project_urls": {
        "Homepage": "https://github.com/dtPaTh/Dqlmagic"
    },
    "split_keywords": [
        "notebook",
        " jupyter",
        " dql",
        " dynatrace query language"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed04b44741ab4515fa3bbaa370de14c523b5c8a8c0a7125d837d61e1b5951d2e",
                "md5": "77c417fe8ee3e840a3384313b2edc4df",
                "sha256": "db082dd89cf2e93dbd01b8622eab0602f65dac8511f33da155e583f9dea9ac35"
            },
            "downloads": -1,
            "filename": "dqlmagic-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "77c417fe8ee3e840a3384313b2edc4df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5138,
            "upload_time": "2024-06-28T12:10:38",
            "upload_time_iso_8601": "2024-06-28T12:10:38.944783Z",
            "url": "https://files.pythonhosted.org/packages/ed/04/b44741ab4515fa3bbaa370de14c523b5c8a8c0a7125d837d61e1b5951d2e/dqlmagic-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8806e1e621b3eaf2aab87b06fc2868ef581ef9d369e4353d733938d38c96475c",
                "md5": "b91643b8965574772b2ed708fc8e2208",
                "sha256": "ac13343a84b780e2bc06dbd7a1a43259e78d78a3d305a66261102a8adaf8a9d6"
            },
            "downloads": -1,
            "filename": "dqlmagic-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b91643b8965574772b2ed708fc8e2208",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4939,
            "upload_time": "2024-06-28T12:10:40",
            "upload_time_iso_8601": "2024-06-28T12:10:40.429185Z",
            "url": "https://files.pythonhosted.org/packages/88/06/e1e621b3eaf2aab87b06fc2868ef581ef9d369e4353d733938d38c96475c/dqlmagic-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-28 12:10:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dtPaTh",
    "github_project": "Dqlmagic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dqlmagic"
}
        
Elapsed time: 3.88494s