Skip to content

Instantly share code, notes, and snippets.

@gspncr
gspncr / drop-app.md
Created October 14, 2020 14:44
Demo New Relic Data Drop Rules

Drop Application

Replace accountId and of course, test out the rule to match your use case

mutation {
    nrqlDropRulesCreate(accountId: 1147177, rules: [
        {
            action: DROP_DATA
 nrql: "SELECT * FROM TestEvent WHERE appName='NR-One Production'"
@gspncr
gspncr / curl.md
Last active October 6, 2020 12:57
New Relic Logs Size

New Relic Log Size Demo

add your own license key

EU region - change the request url to https://log-api.eu.newrelic.com/log/v1

here is a cURL request with a 10k string

curl --location --request POST 'https://log-api.newrelic.com/log/v1' \
{
"dashboard": {
"metadata": { "version": 1 },
"title": "k6 Sample Dashboard",
"icon": "line-chart",
"visibility": "all",
"editable": "editable_by_all",
"filter": null,
"widgets": [
{
@gspncr
gspncr / k6-new-relic-demo.md
Last active December 14, 2021 18:07
k6 and New Relic demo stack

Assumptions: a New Relic account and Ubuntu 18. Works on a t2.micro

k6 installation instructions from their docs

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install k6
@gspncr
gspncr / findGuids.py
Last active August 6, 2020 14:26
New Relic NerdGraph GUID Lookup
import requests, json
graphQLEndpoint = 'https://api.newrelic.com/graphql'
#graphQLEndpoint = 'https://api.eu.newrelic.com/graphql'
APIKey = '<your key here>'
headers = {
"Content-Type": 'application/json',
"API-Key": APIKey
}
@gspncr
gspncr / new-relic-snmp-demo.md
Last active October 1, 2020 17:49
New Relic 💙 SNMP

Demo SNMP and New Relic Setup

Assumptions: Ubuntu 18 and New Relic Infra already installed.

Install SNMP, SNMP daemon, optionally mibs downloader

sudo apt install snmpd snmp snmp-mibs-downloader

Replace snmpd.conf with contents of below file. Really we are just commenting out line 15 and uncommenting line 17. Adding line 64 and line 185.

@gspncr
gspncr / apache-v2-integrations.yml
Last active September 28, 2020 10:03
new relic nri-apache version 2 integration example for multiple apache instances.
integrations:
- name: apache-server-metrics
integration_name: com.newrelic.apache
command: metrics
arguments:
status_url: http://127.0.0.1:90/server-status?auto
remote_monitoring: true
labels:
env: production
role: load_balancer
@gspncr
gspncr / food-agency-new-relic-synthetics.js
Created October 30, 2019 11:18
New Relic Synthetics script to check for new food allergy alerts
var parseString = require('xml2js').parseString;
var $http = require('request');
// Get the New Relic status RSS feed
$http.get('https://www.food.gov.uk/rss-feed/alerts-allergy', function(err, response, body) {
parseString(body, function(err, result){
// Parse the RSS, and get the latest incident
var latestIncident = result.rss.channel[0].item[0];
// Push the incident details to Insights
@gspncr
gspncr / post-monitor-to-cURL.json
Created October 27, 2019 18:50
New Relic Partner Enablement to cURL
POST /synthetics/api/v3/monitors HTTP/1.1
Host: synthetics.newrelic.com
X-Api-Key: {{apiKey}}
Content-Type: application/json
{
"name": "Gary Homepage",
"type": "SIMPLE",
"frequency": 30,
"uri": "https://my-lab-4-hostname.com:8080/wordpress/",
"locations": ["AWS_US_WEST_1","AWS_EU_WEST_2"],
@gspncr
gspncr / post-monitor-to-postman.json
Created October 27, 2019 18:49
New Relic Partner enablement - post monitor to json
https://synthetics.newrelic.com/synthetics/api/v3/monitors
Header:
X-Api-Key {{apiKey}}
Content-Type application/json
Body:
{
"name": "Gary Homepage",
"type": "SIMPLE",
"frequency": 30,
"uri": "https://my-lab-4-hostname.com:8080/wordpress/",