def test_logs_batch_query():
    client = LogsQueryClient(_credential())

    requests = [
        LogsQueryRequest(query="AzureActivity | summarize count()",
                         timespan="PT1H",
                         workspace=os.environ['LOG_WORKSPACE_ID']),
        LogsQueryRequest(query="""AppRequests | take 10  |
                summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId""",
                         timespan="PT1H",
                         workspace=os.environ['LOG_WORKSPACE_ID']),
        LogsQueryRequest(query="AppRequests | take 2",
                         workspace=os.environ['LOG_WORKSPACE_ID']),
    ]
    response = client.batch_query(requests)

    assert len(response.responses) == 3
Пример #2
0
            "query": "AzureActivity | summarize count()",
            "timespan": "PT1H"
        },
        "method": "POST",
        "path": "/query",
        "workspace": os.environ['LOG_WORKSPACE_ID']
    },
    {
        "id": "2",
        "headers": {
            "Content-Type": "application/json"
        },
        "body": {
            "query": "AzureActivity | summarize count()",
            "timespan": "PT1H"
        },
        "method": "POST",
        "path": "/fakePath",
        "workspace": os.environ['LOG_WORKSPACE_ID']
    }
]
response = client.batch_query(requests)

for response in response.responses:
    body = response.body
    if not body.tables:
        print("Something is wrong")
    else:
        for table in body.tables:
            df = pd.DataFrame(table.rows, columns=[col.name for col in table.columns])
            print(df)