r7insight-python is a plugin library designed to integrate Python's standard logging module with Rapid7 Insight (formerly InsightOps). It enables sending log messages, and optionally method execution times, CPU, and memory statistics to your Rapid7 Insight account. The library leverages asynchronous operations for log dispatch and is currently at version 1.0.1. Releases appear to be infrequent, suggesting a mature or maintenance phase.
pip install r7insight_pythonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic logging to Rapid7 Insight. You need to obtain a Token UUID from a 'Token TCP' log source in your Rapid7 Insight account and specify your region. The example retrieves these values from environment variables or uses placeholders.
Account for asynchronous delivery in testing and production; allow time for logs to be processed and appear in the Insight console.
Ensure you create a log in Rapid7 Insight, select 'Token TCP' as the source type, and use the generated Token UUID and the correct region (e.g., 'us', 'eu') when initializing `R7InsightHandler`.
Check network firewalls and proxy settings. As a last resort, for debugging or non-sensitive data, you can set `use_tls=False` and `allow_plaintext_fallback=True` in the `R7InsightHandler` constructor, but this sends logs over plain HTTP on port 80 and is not recommended for production. Example: `R7InsightHandler(TOKEN, REGION, use_tls=False, allow_plaintext_fallback=True)`.
Use Python 3.x for new projects. If migrating from Python 2, ensure all code is Python 3 compatible before using this library.
Verify that your server has outbound access to the Rapid7 Insight ingest endpoint on port 443 (or 80 if `use_tls=False`). Check local firewall, corporate proxy, and DNS resolution. Setting `use_tls=False, allow_plaintext_fallback=True` in `R7InsightHandler` can help diagnose if TLS is the specific issue, but should be used with caution.
Double-check the `TOKEN` and `REGION` values passed to `R7InsightHandler`. Ensure your log source in Rapid7 Insight is configured as 'Token TCP'. Confirm there are no 'Unable to connect' messages in your application logs. Remember the appender is asynchronous, so a delay is expected.