Skip to content

Instantly share code, notes, and snippets.

@konradkonrad
Last active January 29, 2018 16:49
Show Gist options
  • Save konradkonrad/93db5cd2f067cb2c3343ed22bd992629 to your computer and use it in GitHub Desktop.
Save konradkonrad/93db5cd2f067cb2c3343ed22bd992629 to your computer and use it in GitHub Desktop.
Get you started dashboard for grafana & eth.events
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": 4,
"links": [],
"refresh": "1m",
"rows": [
{
"collapse": false,
"height": 250,
"panels": [
{
"content": "# Welcome to eth.events grafana frontend\n\n.",
"id": 3,
"links": [],
"mode": "markdown",
"span": 12,
"title": "Welcome to eth.events grafana frontend",
"type": "text"
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
},
{
"collapse": true,
"height": 250,
"panels": [
{
"content": "# Mapping Help\n\nThe indexed data is almost identical with the output from `go-ethereum`. Some fields however are mapped to several representations for convenience. For example:\n- numbers below `64bit` have two representations: e.g. \n - `blockNumber.raw` (with the original `hex` value) and \n - `blockNumber.num` (with a `long` representation of the value).\n- the `value` field of a transaction is mapped to \n - `value.eth` (as a `double` that contains`web3.fromWei(value, 'ether')`), \n - `value.padded` (a zero-padded version of the `hex` value that allows string sorting) and \n - `value.raw` (the original unpadded `hex` value)\n- hashes and addresses are mapped as `keyword`, which allows for efficient aggregations and searching via `match` queries\n\n### IDs\n- the `id` of a `block` is its `hash`\n- the `id` of a `tx` is its `hash`\n- the `id` of a `log` is its `transactionHash` + `_` + `logIndex`\n\n### Parent/Child Mapping\n`block`, `tx` and `log` are mapped in a parent child relation[0]:\n- every indexed `log` has a parent `tx` (in the `_parent` field)\n- every indexed `tx` has a parent `block` (in the `_parent` field)\n\n### Transformations\n\nThe idea behind keeping the `.raw` representations is, that they allow to use the data in standard tooling (i.e. `web3`, `web3-py`, ...) without much further conversions, other than collapsing the `<field>.raw` content to the `<field>` value, e.g.\n```\ndef collapse_raw(doc):\n result = dict()\n for field in doc.keys():\n if hasattr(doc[field], 'get') and 'raw' in doc[field]:\n result[field] = doc[field]['raw']\n else:\n result[field] = doc[field]\nreturn result\n```\n\n#### References\n[0] https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-parent-field.html",
"id": 7,
"links": [],
"mode": "markdown",
"span": 3,
"title": "Mapping explanation",
"type": "text"
},
{
"content": "# Mapping for `_type: block`\n```\ndifficulty.padded: keyword\ndifficulty.raw: keyword\nextraData: keyword\ngasLimit.num: long\ngasLimit.raw: keyword\ngasUsed.num: long\ngasUsed.raw: keyword\nhash: keyword\nlogsBloom: keyword\nminer: keyword\nminingNonce: keyword\nmixHash: keyword\nnumber.num: long\nnumber.raw: keyword\nparentHash: keyword\nreceiptsRoot: keyword\nsha3Uncles: keyword\nsize.num :long\nsize.raw: keyword\nstateRoot: keyword\ntimestamp: date\ntotalDifficulty.padded: keyword\ntotalDifficulty.raw: keyword\ntransactions: keyword\ntransactionsRoot: keyword\nuncles: keyword\n```",
"id": 4,
"links": [],
"mode": "markdown",
"span": 3,
"title": "Block Mapping",
"type": "text"
},
{
"content": "# Mapping for `_type: tx`\n\n```\nblockHash: keyword\nblockNumber.num: long\nblockNumber.raw: keyword\ncontractAddress: keyword\ncumulativeGasUsed.num: long\ncumulativeGasUsed.raw: keyword\nfrom: keyword\ngas.num: long\ngas.raw: keyword\ngasPrice.num: long\ngasPrice.raw: keyword\ngasUsed.num: long\ngasUsed.raw: keyword\nhash: keyword\ninput: keyword\nlogsBloom: keyword\nnonce.num: long\nnonce.raw: keyword\nr: keyword\nroot: keyword\ns: keyword\nstatus: keyword\ntimestamp: date\nto: keyword\ntransactionIndex.num: long\ntransactionIndex.raw: keyword\nv: keyword\nvalue.padded: keyword\nvalue.raw: keyword\nvalue.eth: double\n```",
"id": 5,
"links": [],
"mode": "markdown",
"span": 3,
"title": "Transaction Mapping",
"type": "text"
},
{
"content": "# Mapping for `_type: log`\n\n```\naddress: keyword\nblockHash: keyword\nblockNumber.num: long\nblockNumber.raw: keyword\ndata: keyword\nlogIndex.num: long\nlogIndex.raw: keyword\nremoved: keyword\nsignature: keyword\ntimestamp: date\ntopics: keyword\ntransactionHash: keyword\ntransactionIndex.num: long\ntransactionIndex.raw: keyword\n```",
"id": 6,
"links": [],
"mode": "markdown",
"span": 3,
"title": "Log Mapping",
"type": "text"
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Mapping Help",
"titleSize": "h6"
},
{
"collapse": false,
"height": "550px",
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"id": 2,
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "No of Transactions",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "select field",
"id": "1",
"type": "count"
}
],
"query": "_type: \"tx\"",
"refId": "A",
"timeField": "timestamp"
},
{
"alias": "Block Gas Used / 1000",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "gasUsed.num",
"id": "1",
"inlineScript": "_value / 1000",
"meta": {},
"settings": {
"script": {
"inline": "_value / 1000"
}
},
"type": "avg"
}
],
"query": "_type: \"block\"",
"refId": "B",
"timeField": "timestamp"
},
{
"alias": "Block Gas Limit / 1000",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "gasLimit.num",
"id": "1",
"inlineScript": "_value / 1000",
"meta": {},
"settings": {
"script": {
"inline": "_value / 1000"
}
},
"type": "avg"
}
],
"query": "_type: \"block\"",
"refId": "C",
"timeField": "timestamp"
},
{
"alias": "No of Events",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "select field",
"id": "1",
"type": "count"
}
],
"query": "_type: \"log\"",
"refId": "D",
"timeField": "timestamp"
},
{
"alias": "Block No",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"hide": true,
"metrics": [
{
"field": "number.num",
"id": "1",
"inlineScript": "_value / 100",
"meta": {},
"pipelineAgg": "select metric",
"settings": {
"script": {
"inline": "_value / 100"
}
},
"type": "avg"
}
],
"refId": "E",
"timeField": "timestamp"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Block stats",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Block Stats",
"titleSize": "h6"
},
{
"collapse": false,
"height": 432,
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"id": 1,
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "Average blockNumber.num"
}
],
"spaceLength": 10,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Average tx cost / 10000000",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"hide": false,
"metrics": [
{
"field": "blockNumber.num",
"id": "5",
"inlineScript": "(doc['gasPrice.num'].value * doc['gasUsed.num'].value) / 10000000",
"meta": {},
"settings": {
"script": {
"inline": "(doc['gasPrice.num'].value * doc['gasUsed.num'].value) / 10000000"
}
},
"type": "avg"
}
],
"query": "",
"refId": "A",
"timeField": "timestamp"
},
{
"alias": "Average ETH sent * 10000000",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "value.eth",
"id": "1",
"inlineScript": "_value * 10000000",
"meta": {},
"settings": {
"script": {
"inline": "_value * 10000000"
}
},
"type": "avg"
}
],
"refId": "B",
"timeField": "timestamp"
},
{
"alias": "Average gasPrice / 100",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "gasPrice.num",
"id": "1",
"inlineScript": "_value / 100",
"meta": {},
"settings": {
"script": {
"inline": "_value / 100"
}
},
"type": "avg"
}
],
"refId": "C",
"timeField": "timestamp"
},
{
"alias": "Average gasUsed * 1000",
"bucketAggs": [
{
"field": "timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"dsType": "elasticsearch",
"metrics": [
{
"field": "gasUsed.num",
"id": "1",
"inlineScript": "_value * 1000",
"meta": {},
"settings": {
"script": {
"inline": "_value * 1000"
}
},
"type": "avg"
}
],
"refId": "D",
"timeField": "timestamp"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Transaction stats",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "lengthkm",
"label": null,
"logBase": 1,
"max": "1000000000",
"min": null,
"show": false
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Transaction Stats",
"titleSize": "h6"
}
],
"schemaVersion": 14,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-90d",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "grafana eth.events",
"version": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment