All Projects → newrelic → newrelic-telemetry-sdk-python

newrelic / newrelic-telemetry-sdk-python

Licence: Apache-2.0 License
A python library to send data to New Relic!

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to newrelic-telemetry-sdk-python

micrometer-registry-newrelic
Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Stars: ✭ 27 (+17.39%)
Mutual labels:  telemetry, newrelic
newrelic-telemetry-sdk-java
Java library for sending telemetry data to New Relic
Stars: ✭ 34 (+47.83%)
Mutual labels:  telemetry, newrelic
pprzlink
Message and communication library for the Paparazzi UAV system
Stars: ✭ 17 (-26.09%)
Mutual labels:  telemetry
Windows-Optimize-Harden-Debloat
Fully Optimize, Harden, and Debloat Windows 10 and Windows 11 Deployments to Windows Best Practices and DoD STIG/SRG Requirements. The ultimate Windows 10 & 11 security and privacy script!
Stars: ✭ 304 (+1221.74%)
Mutual labels:  telemetry
Windows.10.DNS.Block.List
Windows DNS Block List
Stars: ✭ 18 (-21.74%)
Mutual labels:  telemetry
newrelic-cli
Newrelic client written in Python providing both CLI and Python interfaces
Stars: ✭ 26 (+13.04%)
Mutual labels:  newrelic
BulletGCSS
A High Caliber Ground Control Station System designed for the 21st century lifestyle
Stars: ✭ 29 (+26.09%)
Mutual labels:  telemetry
TraceEvent
Trace events in real time sessions
Stars: ✭ 26 (+13.04%)
Mutual labels:  telemetry
gnmi-map
gNMI service map
Stars: ✭ 23 (+0%)
Mutual labels:  telemetry
nostromo
BLDC ESC firmware (GPLv3.0)
Stars: ✭ 36 (+56.52%)
Mutual labels:  telemetry
telemetry registry
A library for declaration and discovery of telemetry events
Stars: ✭ 25 (+8.7%)
Mutual labels:  telemetry
tdm
Telemetry Data Mapper to ease data discovery, correlation, and usage with YANG, MIBs, etc.
Stars: ✭ 33 (+43.48%)
Mutual labels:  telemetry
WeConnect-python
Python API for the Volkswagen WeConnect Services
Stars: ✭ 27 (+17.39%)
Mutual labels:  telemetry
tinypacks
A data serialization format for constrained environments like 8-bit and 16-bit microcontrollers.
Stars: ✭ 30 (+30.43%)
Mutual labels:  telemetry
WeConnect-cli
Commandline Interface to interact with the Volkswagen WeConnect Services
Stars: ✭ 27 (+17.39%)
Mutual labels:  telemetry
newrelic-context
Contains different helpers to make life easier with NewRelic and Context.
Stars: ✭ 21 (-8.7%)
Mutual labels:  newrelic
toptout
📡 Easily opt-out from telemetry collection
Stars: ✭ 89 (+286.96%)
Mutual labels:  telemetry
arcus.observability
Observability with Microsoft Azure in a breeze.
Stars: ✭ 24 (+4.35%)
Mutual labels:  telemetry
jradio
Software radio decoding
Stars: ✭ 40 (+73.91%)
Mutual labels:  telemetry
kotori
A flexible data historian based on InfluxDB, Grafana, MQTT and more. Free, open, simple.
Stars: ✭ 73 (+217.39%)
Mutual labels:  telemetry

header

New Relic Telemetry SDK

ci coverage docs black

newrelic-telemetry-sdk-python provides a Python library for sending data into New Relic using the Python urllib3 library.

See dimensional metrics, events, logs, and spans/traces in New Relic, without having to use an agent!

Installing newrelic_telemetry_sdk

To start, the newrelic-telemetry-sdk package must be installed. To install through pip:

$ pip install newrelic-telemetry-sdk

If that fails, download the library from its GitHub page and install it using:

$ python setup.py install

Reporting your first metric

There are 3 different types of metrics:

  • GaugeMetric
  • CountMetric
  • SummaryMetric

Metric descriptions

Metric type Interval required Description Example
Gauge No A single value at a single point in time. Room Temperature.
Count Yes Track the total number of occurrences of an event. Number of errors that have occurred.
Summary Yes Track count, sum, min, and max values over time. The summarized duration of 100 HTTP requests.

Example

The example code assumes you've set the following environment variables:

  • NEW_RELIC_INSERT_KEY
import os
import time
from newrelic_telemetry_sdk import GaugeMetric, CountMetric, SummaryMetric, MetricClient

metric_client = MetricClient(os.environ["NEW_RELIC_INSERT_KEY"])

temperature = GaugeMetric("temperature", 78.6, {"units": "Farenheit"})

# Record that there have been 5 errors in the last 2 seconds
errors = CountMetric(name="errors", value=5, interval_ms=2000)

# Record a summary of 10 response times over the last 2 seconds
summary = SummaryMetric(
    "responses", count=10, min=0.2, max=0.5, sum=4.7, interval_ms=2000
)

batch = [temperature, errors, summary]
response = metric_client.send_batch(batch)
response.raise_for_status()
print("Sent metrics successfully!")

Reporting your first event

Events represent a record of something that has occurred on a system being monitored. The example code assumes you've set the following environment variables:

  • NEW_RELIC_INSERT_KEY
import os
import time
from newrelic_telemetry_sdk import Event, EventClient

# Record that a rate limit has been applied to an endpoint for an account
event = Event(
    "RateLimit", {"path": "/v1/endpoint", "accountId": 1000, "rejectRatio": 0.1}
)

event_client = EventClient(os.environ["NEW_RELIC_INSERT_KEY"])
response = event_client.send(event)
response.raise_for_status()
print("Event sent successfully!")

Reporting your first log message

Log messages are generated by applications, usually via the Python logging module. These messages are used to audit and diagnose issues with an operating application. The example code assumes you've set the following environment variables:

  • NEW_RELIC_INSERT_KEY
import os

from newrelic_telemetry_sdk import Log, LogClient

log = Log("Hello World!")

log_client = LogClient(os.environ["NEW_RELIC_INSERT_KEY"])
response = log_client.send(log)
response.raise_for_status()
print("Log sent successfully!")

Reporting your first span

Spans provide an easy way to time components of your code. The example code assumes you've set the following environment variables:

  • NEW_RELIC_INSERT_KEY
import os
import time
from newrelic_telemetry_sdk import Span, SpanClient

with Span(name="sleep") as span:
    time.sleep(0.5)

span_client = SpanClient(os.environ["NEW_RELIC_INSERT_KEY"])
response = span_client.send(span)
response.raise_for_status()
print("Span sleep sent successfully!")

Find and use data

Tips on how to find and query your data in New Relic:

For general querying information, see:

Limitations

The New Relic Telemetry APIs are rate limited. Please reference the documentation for New Relic Metrics API and New Relic Trace API requirements and limits on the specifics of the rate limits.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].