Skip to content

Commit

Permalink
Merge pull request #5 from ambrosus/add-eth-adresses-metrics
Browse files Browse the repository at this point in the history
Add eth adresses metrics
  • Loading branch information
Eshanchik authored Nov 14, 2023
2 parents 19b15ad + b6efec1 commit ac8becb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create and publish image

on:
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: parity_exporter
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/ambrosus/parity-exporter

- name: Build and push
uses: docker/build-push-action@v2
with:
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Move cachee
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
16 changes: 12 additions & 4 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ function createMetrics(registry: Registry, nodeURL: string): ICreateMetrics {
'Current Block of Parity Node',
[]
),
parityUp: createGauge('parity_up', 'Parity up/down', [])
parityUp: createGauge('parity_up', 'Parity up/down', []),
nodeAddress: createGauge('parity_node_address', 'Ethereum Address of the Node', ['address'])
};

return async () => {
const [
clientVersion,
syncInfo,
latestBlockNumber,
peersInfo
peersInfo,
nodeAddress
] = await Promise.all([
makeRequest(nodeURL, 'web3_clientVersion'),
makeRequest(nodeURL, 'eth_syncing'),
makeRequest(nodeURL, 'eth_blockNumber'),
makeRequest(nodeURL, 'parity_netPeers')
makeRequest(nodeURL, 'parity_netPeers'),
makeRequest(nodeURL, 'eth_coinbase') // Make Eth node adresses
]);

// See if call failed
Expand Down Expand Up @@ -80,5 +83,10 @@ function createMetrics(registry: Registry, nodeURL: string): ICreateMetrics {
gauges.activePeers.set(peersInfo.active);
gauges.connectedPeers.set(peersInfo.connected);
gauges.maxPeers.set(peersInfo.max);

// node address
if (nodeAddress !== false) {
gauges.nodeAddress.set({ address: nodeAddress }, 1);
}
};
}
}

0 comments on commit ac8becb

Please sign in to comment.