use this repository to spin up a container that pulls data directly from Ethereum using Infura and Web3.py library. the data is then posted as custom events to the New Relic Metric API for querying and visualization.
Web3.py is a Python library for interacting with Ethereum: https://web3py.readthedocs.io/en/stable/
Infura is a service that provides a remote Ethereum node for free - no $$$ for my own node :')
- update the
infra_url
parameter inapp.py
with your own Infura API - you can create a free account and API key here - update the
account_id
andinsert_api_key
parameters with your New Relic account number and Insert API Key
you can run this locally on your machine
docker build [OPTIONS] PATH | URL | -
(i.e., docker build -t web3-repo .
)
BUT❗
I wanted to set it up as a scheduled task with ECS to generate a continual flow of Ethereum data to my New Relic dashboards:
-
create Elastic Container Repository to store image
aws ecr create-repository --repository-name web3-repo --region region
-
tag the image with your
repositoryUri
docker tag web3-image aws_account_id.dkr.ecr.region.amazonaws.com/web3-repo
-
run the
aws ecr get-login-password
command
aws ecr get-login-password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
-
push the image to Amazon ECR with the repositoryUri value from the earlier step.
docker push aws_account_id.dkr.ecr.region.amazonaws.com/web3-repo
from there you can set up an EventBridge rule to run as a scheduled task (i.e., like a cronjob, run at certain times or intervals as desired)
this will generate the following custom events:
walletBalance
: contains thebalance
of wallets held by Snoop Dogg, Paris Hilton, Lindsay Lohan, Mark Cuban, and Serena WilliamsblockStatz
: contains thedifficulty
,gasLimit
,gasUsed
,miner
,number
, andsize
of latest block minedgasPrice
: contains the currentprice
or fee per transaction on Ethereum in wei - one ether = 1,000,000,000,000,000,000 wei (10^18)
SELECT * FROM walletBalance
SELECT * FROM blockStatz
SELECT * FROM gasPrice
find and replace the accountId
parameter in the dashboard.json
file and then import the json to New Relic to use this example dashboard