Skip to main content

Python analytics client for the Micromegas observability platform

Project description

Micromegas

Python analytics client for https://github.com/madesroches/micromegas/

📖 Complete Python API Documentation - Comprehensive guide with all methods, examples, and advanced patterns

Example usage

Query the 2 most recent log entries from the flightsql service

import datetime
import micromegas

# Connect to local server
client = micromegas.connect()
sql = """
SELECT time, process_id, level, target, msg
FROM log_entries
WHERE level <= 4
AND exe LIKE '%flight%'
ORDER BY time DESC
LIMIT 2
"""

now = datetime.datetime.now(datetime.timezone.utc)
begin = now - datetime.timedelta(minutes=2)
end = now
df = client.query(sql, begin, end)
print(df)
time process_id level target msg
0 2024-10-03 18:17:56.087543714+00:00 1db06afc-1c88-47d1-81b3-f398c5f93616 4 acme_telemetry::trace_middleware response status=200 OK uri=/analytics/query
1 2024-10-03 18:17:53.924037729+00:00 1db06afc-1c88-47d1-81b3-f398c5f93616 4 micromegas_analytics::lakehouse::query query sql=
SELECT time, process_id, level, target, msg
FROM log_entries
WHERE level <= 4
AND exe LIKE '%analytics%'
ORDER BY time DESC
LIMIT 2

Query the 10 slowest top level spans in a trace within a specified time window

import datetime
import micromegas

client = micromegas.connect()

# First find a stream ID
end = datetime.datetime.now(datetime.timezone.utc)
begin = end - datetime.timedelta(hours=1)
streams = client.query_streams(begin, end, limit=1)

if not streams.empty:
    stream_id = streams['stream_id'].iloc[0]
    
    sql = """
    SELECT begin, end, duration, name
    FROM view_instance('thread_spans', '{}')
    WHERE depth=1
    ORDER BY duration DESC
    LIMIT 10
    """.format(stream_id)
    
    spans = client.query(sql, begin, end)
    print(spans)
begin end duration name
0 2024-10-03 18:00:59.308952900+00:00 2024-10-03 18:00:59.371890+00:00 62937100 FEngineLoop::Tick
1 2024-10-03 18:00:58.752476800+00:00 2024-10-03 18:00:58.784389+00:00 31912200 FEngineLoop::Tick
2 2024-10-03 18:00:58.701507300+00:00 2024-10-03 18:00:58.731479500+00:00 29972200 FEngineLoop::Tick
3 2024-10-03 18:00:59.766343100+00:00 2024-10-03 18:00:59.792513700+00:00 26170600 FEngineLoop::Tick
4 2024-10-03 18:00:59.282902100+00:00 2024-10-03 18:00:59.308952500+00:00 26050400 FEngineLoop::Tick
5 2024-10-03 18:00:59.816034500+00:00 2024-10-03 18:00:59.841376900+00:00 25342400 FEngineLoop::Tick
6 2024-10-03 18:00:58.897813100+00:00 2024-10-03 18:00:58.922769700+00:00 24956600 FEngineLoop::Tick
7 2024-10-03 18:00:59.860637+00:00 2024-10-03 18:00:59.885523700+00:00 24886700 FEngineLoop::Tick
8 2024-10-03 18:00:58.630051300+00:00 2024-10-03 18:00:58.654871500+00:00 24820200 FEngineLoop::Tick
9 2024-10-03 18:00:57.952279800+00:00 2024-10-03 18:00:57.977024+00:00 24744200 FEngineLoop::Tick

Quick Start

For a complete getting started guide, see the Python API Documentation.

Schema Reference

For complete schema information including all available tables, columns, and data types, see the Schema Reference.

SQL Reference

The Micromegas analytics service is built on Apache DataFusion. For SQL syntax and functions, see the Apache DataFusion SQL Reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

micromegas-0.23.0.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

micromegas-0.23.0-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file micromegas-0.23.0.tar.gz.

File metadata

  • Download URL: micromegas-0.23.0.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for micromegas-0.23.0.tar.gz
Algorithm Hash digest
SHA256 9604142349afbf98ddd8f7ed6f366628d9e8ceb8e7b73e6c1f5b0e79bbe3097e
MD5 1bc54e482fdcd11f57178a8a0c5e4563
BLAKE2b-256 5d3a6956e990fdc12e18756d4b6e7a5d188083ec6d302b8caff239e641e1c724

See more details on using hashes here.

File details

Details for the file micromegas-0.23.0-py3-none-any.whl.

File metadata

  • Download URL: micromegas-0.23.0-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for micromegas-0.23.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e866511429f5ac5802c680eaef9a9e33e5a8377cea111c605be170b05335635
MD5 0bd0df5176f68fa0eec79b6a69c016d2
BLAKE2b-256 1711efde1016511144cf6f5f68671c8a892e44ef9cedb3aff8c83e3919fe474b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page