Skip to main content

Micromegas

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

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

For a remote or authenticated deployment, use micromegas.connect_with_profile("prod") instead of micromegas.connect() — it reads a named profile from ~/.micromegas/config.json and picks the auth mechanism it names (a static API key, OIDC, or none).

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.

Metadata

Release files for micromegas 0.31.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for micromegas 0.31.0
File Size Uploaded
micromegas-0.31.0.tar.gz 67.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for micromegas 0.31.0
File Interpreter ABI Platform
micromegas-0.31.0-py3-none-any.whl Python 3 none any Details

Total release size: 144.9 kB

Release files / micromegas-0.31.0.tar.gz

Download URL micromegas-0.31.0.tar.gz
Size 67.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4d9d7118411c202628036da123a3b62d6a589c59bc1830cbc0eed13622e2d279
BLAKE2b-256 checksum
How to use checksums
99a059a728c037325016bd348da5417d19e207a0873c8603ddf033ab3fac8997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.3 Linux/6.18.33.2-microsoft-standard-WSL2

Release files / micromegas-0.31.0-py3-none-any.whl

Download URL micromegas-0.31.0-py3-none-any.whl
Size 77.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e1cb28c693e9e9af22f60a70c8484b1372331ad0547c120d823b4a4a689a84b
BLAKE2b-256 checksum
How to use checksums
dfb3f9445a86be1ded8e99075daa0aeeaa514d7854a49fc45040e2d6b6667412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.3 Linux/6.18.33.2-microsoft-standard-WSL2

Release history Release notifications | RSS feed

0.31.1

2 release files

This release

0.31.0 This release

2 release files

0.29.0

2 release files

0.27.0

2 release files

0.26.0

2 release files

0.25.0

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.15.3

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page