Define New Relic dashboards as code and reconcile them to an account
Project description
newrelic-as-code
Define New Relic dashboards as code and reconcile them to an account.
New Relic resources should be defined in version-controlled Python and reconciled to the account on deploy, never hand-edited in the UI. You describe dashboards as pydantic models and the library handles finding the resources it manages, creating/updating/deleting them to match your declared set, and refusing to clobber anything it didn't create.
Reconcile is safe by design:
- Managed by tag. The library only touches dashboards carrying its
managed-bytag. A same-named dashboard without the tag is refused, never overwritten — so hand-built dashboards are safe. - Orphan cleanup. A managed dashboard that's no longer in your declared set is deleted.
- Dry run. Pass
dry_run=Trueto print what would change without touching the account.
Installation
pip install newrelic-as-code
Usage
from newrelic_as_code import (
Dashboard,
NewRelicUpdater,
NrqlQuery,
Page,
Widget,
EU_ENDPOINT,
)
dashboard = Dashboard(
name='My service',
pages=[
Page(
name='Overview',
widgets=[
Widget(
title='Throughput',
visualization='viz.line',
column=1,
row=1,
queries=[
NrqlQuery(
query='SELECT rate(count(*), 1 minute) '
'FROM Transaction TIMESERIES',
),
],
),
],
),
],
)
updater = NewRelicUpdater(
account_id=1234567,
api_key='NRAK-...',
# Defaults to the US region; pass EU_ENDPOINT (or any full URL) for others.
endpoint=EU_ENDPOINT,
# The tag that marks dashboards this tool owns. Choose a value unique to your
# deployment so several deployments can coexist in one account.
managed_tag_value='my-service-deploy',
)
updater.sync([dashboard])
Notes
- Account id.
account_idis the account dashboards are created in, and is injected into anyNrqlQuerythat doesn't set its ownaccount_ids. Setaccount_idson a query explicitly to query across (or a different) account. raw_configuration.Widget.raw_configurationis merged into New Relic'srawConfigurationverbatim, so any chart option (units, colors, markers, thresholds, yAxis, gauge settings, …) is available without the library modelling it.- Variables. Dashboard-level template variables are supported via the
Variablemodel andDashboard(variables=[...]). - No builder. The library's surface is the plain
Dashboard/Page/Widget/NrqlQuery/Variablemodel tree — you construct those directly. Any layout/composition helpers (grid math, managed banners) belong in your own code, since they're specific to how you lay dashboards out. - Extensible reconcile.
sync()reconciles dashboards today. The reconcile core (find-by-managed-tag → create/update/delete-orphaned → refuse-unmanaged → dry-run) is resource-agnostic, so alert policies/conditions can be added as additional resource types later without reshaping it.
License
MIT
Not affiliated with or endorsed by New Relic, Inc. "New Relic" is a trademark of New Relic, Inc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file newrelic_as_code-0.1.0.tar.gz.
File metadata
- Download URL: newrelic_as_code-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4a5c1e8969e78dc22365b08b4e77b60292ba653dae8289a803a12a5683130e0
|
|
| MD5 |
af6c6d725370c9de189d53275ae36dab
|
|
| BLAKE2b-256 |
ae81fe58c61645521927957546d1f250059c1c2dcea5a448ce338dd486e0e7d1
|
Provenance
The following attestation bundles were made for newrelic_as_code-0.1.0.tar.gz:
Publisher:
ci.yaml on ipeterov/newrelic-as-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newrelic_as_code-0.1.0.tar.gz -
Subject digest:
f4a5c1e8969e78dc22365b08b4e77b60292ba653dae8289a803a12a5683130e0 - Sigstore transparency entry: 2080293352
- Sigstore integration time:
-
Permalink:
ipeterov/newrelic-as-code@9fe724b5a41f630f78adc352019f8d5488cfb565 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ipeterov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@9fe724b5a41f630f78adc352019f8d5488cfb565 -
Trigger Event:
push
-
Statement type:
File details
Details for the file newrelic_as_code-0.1.0-py3-none-any.whl.
File metadata
- Download URL: newrelic_as_code-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2448b9601173bd390f187a409ed5294273d76db45f9259edaaecb4e991dbc42b
|
|
| MD5 |
12029bf47e8377dce4672286434cebbd
|
|
| BLAKE2b-256 |
d147a817081d50dc09637459da6d37bd33be41e3628f4c7438c8e58130f19187
|
Provenance
The following attestation bundles were made for newrelic_as_code-0.1.0-py3-none-any.whl:
Publisher:
ci.yaml on ipeterov/newrelic-as-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newrelic_as_code-0.1.0-py3-none-any.whl -
Subject digest:
2448b9601173bd390f187a409ed5294273d76db45f9259edaaecb4e991dbc42b - Sigstore transparency entry: 2080293788
- Sigstore integration time:
-
Permalink:
ipeterov/newrelic-as-code@9fe724b5a41f630f78adc352019f8d5488cfb565 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ipeterov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@9fe724b5a41f630f78adc352019f8d5488cfb565 -
Trigger Event:
push
-
Statement type: