Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomasneirynck/0bb360811049f0437411c3b2c058a5f4 to your computer and use it in GitHub Desktop.
Save thomasneirynck/0bb360811049f0437411c3b2c058a5f4 to your computer and use it in GitHub Desktop.
lens_panel_today.json
[
{
"type": "lens",
"embeddableConfig": { // naming refers to implementation detail
"enhancements": { // cruft
"dynamicActions": {
"events": []
}
},
"syncColors": false,// cruft
"syncCursor": true,// cruft
"syncTooltips": false,// cruft
"filters": [],// cruft
"query": {
"esql": "FROM kibana_sample_data_logs | STATS AVG(bytes) by BUCKET(timestamp, 100, ?_tstart, ?_tend)"
},
"attributes": {
"title": "Bar vertical stacked",
"references": [],// cruft
"state": {
"datasourceStates": {
"textBased": { // this is a type of datasource, no need to key this and nest
"layers": { // why do we need to nest this?
"27f63689-18d8-4356-b608-6da242da3b00": { // datasources are a "set" of unique entries and have no layerying, so this seems OK to me.
"index": "e3465e67bdeced2befff9f9dca7ecf9c48504cad68a10efd881f4c7dd5ade28a", // Should not store reference to index, the query is enough
"query": { // odd modeling.
"esql": "FROM kibana_sample_data_logs | STATS AVG(bytes) by BUCKET(timestamp, 100, ?_tstart, ?_tend)"
},
"columns": [ // Should not store state that is known because of the ES|QL statement. This is duplicate info.
{
"columnId": "AVG(bytes)",
"fieldName": "AVG(bytes)",
"label": "AVG(bytes)",
"customLabel": false,
"meta": {
"type": "number",
"esType": "double"
},
"inMetricDimension": true
},
{
"columnId": "BUCKET(timestamp, 100, ?_tstart, ?_tend)",
"fieldName": "BUCKET(timestamp, 100, ?_tstart, ?_tend)",
"label": "BUCKET(timestamp, 100, ?_tstart, ?_tend)",
"customLabel": false,
"meta": {
"type": "date",
"esType": "date"
}
}
],
"timeField": "@timestamp" // This is a duplicate of the index pattern reference, should not be stored here.
}
},
"indexPatternRefs": [ // refs are internal implementation detail
{
"id": "e3465e67bdeced2befff9f9dca7ecf9c48504cad68a10efd881f4c7dd5ade28a",
"title": "kibana_sample_data_logs",
"timeField": "@timestamp"
}
]
}
},
"filters": [], // cruft
"query": { // duplicate! cruft
"esql": "FROM kibana_sample_data_logs | STATS AVG(bytes) by BUCKET(timestamp, 100, ?_tstart, ?_tend)"
},
"visualization": { // ok
"legend": { // cruft
"isVisible": true,
"position": "right"
},
"valueLabels": "hide", // cruft
"fittingFunction": "Linear", // cruft
"axisTitlesVisibilitySettings": { // cruft
"x": true,
"yLeft": true,
"yRight": true
},
"tickLabelsVisibilitySettings": { // cruft
"x": true,
"yLeft": true,
"yRight": true
},
"labelsOrientation": { // cruft
"x": 0,
"yLeft": 0,
"yRight": 0
},
"gridlinesVisibilitySettings": { // cruft
"x": true,
"yLeft": true,
"yRight": true
},
"preferredSeriesType": "bar_stacked", // cruft
"layers": [ // ok, lens is layered visualization
{
"layerId": "27f63689-18d8-4356-b608-6da242da3b00", // odd-naming it refers to a datasource, not a layer
"seriesType": "bar_stacked",
"xAccessor": "BUCKET(timestamp, 100, ?_tstart, ?_tend)",
"accessors": [
"AVG(bytes)"
],
"layerType": "data",// ok, but ordering is poor
"colorMapping": { // cruft
"assignments": [],
"specialAssignments": [
{
"rules": [
{
"type": "other"
}
],
"color": {
"type": "loop"
},
"touched": false // yikes!
}
],
"paletteId": "default",
"colorMode": {
"type": "categorical"
}
}
}
]
},
"adHocDataViews": { // this is a datasource. why have an internal reference?
"e3465e67bdeced2befff9f9dca7ecf9c48504cad68a10efd881f4c7dd5ade28a": {
"id": "e3465e67bdeced2befff9f9dca7ecf9c48504cad68a10efd881f4c7dd5ade28a",
"title": "kibana_sample_data_logs",
"timeFieldName": "@timestamp",
"sourceFilters": [],
"type": "esql",
"fieldFormats": {},
"runtimeFieldMap": {},
"allowNoIndex": false,
"name": "kibana_sample_data_logs",
"allowHidden": false
}
},
"needsRefresh": false // yikes!
},
"visualizationType": "lnsXY" // poor ordering
}
},
"panelIndex": "96684c24-ec71-4061-afd0-1bb7abf55722", // internal implementation detail
"gridData": { // cruft, positioning should work automated too
"i": "96684c24-ec71-4061-afd0-1bb7abf55722",
"y": 0,
"x": 0,
"w": 48,
"h": 11
}
},
{
"type": "lens",
"embeddableConfig": {
"enhancements": {
"dynamicActions": {
"events": []
}
},
"syncColors": false,
"syncCursor": true,
"syncTooltips": false,
"filters": [],
"query": {
"query": "",
"language": "kuery"
},
"attributes": {
"title": "",
"visualizationType": "lnsXY",
"type": "lens",
"references": [
{
"type": "index-pattern",
"id": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62",
"name": "indexpattern-datasource-layer-8f8fdf1c-8b58-4e67-8f38-f0c811bf22d7"
}
],
"state": {
"visualization": {
"legend": {
"isVisible": true,
"position": "right"
},
"valueLabels": "hide",
"fittingFunction": "Linear",
"axisTitlesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"tickLabelsVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"labelsOrientation": {
"x": 0,
"yLeft": 0,
"yRight": 0
},
"gridlinesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"preferredSeriesType": "bar_stacked",
"layers": [
{
"layerId": "8f8fdf1c-8b58-4e67-8f38-f0c811bf22d7",
"accessors": [
"b5976c55-a22f-42fd-9b37-da9b085f7792"
],
"position": "top",
"seriesType": "bar_stacked",
"showGridlines": false,
"layerType": "data",
"colorMapping": {
"assignments": [],
"specialAssignments": [
{
"rules": [
{
"type": "other"
}
],
"color": {
"type": "loop"
},
"touched": false
}
],
"paletteId": "default",
"colorMode": {
"type": "categorical"
}
},
"xAccessor": "bda3174e-977c-467d-a589-adf13335bfb0"
}
]
},
"query": {
"query": "",
"language": "kuery"
},
"filters": [],
"datasourceStates": {
"formBased": {
"layers": {
"8f8fdf1c-8b58-4e67-8f38-f0c811bf22d7": {
"columns": { // this is just a list. using map is not needed.
"bda3174e-977c-467d-a589-adf13335bfb0": {
"label": "@timestamp",
"dataType": "date", // cruft
"operationType": "date_histogram",
"sourceField": "@timestamp",
"isBucketed": true,
"scale": "interval",
"params": { // cruft
"interval": "auto",
"includeEmptyRows": true,
"dropPartials": false
}
},
"b5976c55-a22f-42fd-9b37-da9b085f7792": {
"label": "Average of bytes",
"dataType": "number", // cruft
"operationType": "average",
"sourceField": "bytes",
"isBucketed": false,
"scale": "ratio",
"params": { // cruft
"emptyAsNull": true
}
}
},
"columnOrder": [ // required because of modeling as map iso array.
"bda3174e-977c-467d-a589-adf13335bfb0",
"b5976c55-a22f-42fd-9b37-da9b085f7792"
],
"incompleteColumns": {}, // cruft
"sampling": 1, // cruft
"indexPatternId": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62" // internal references are implementation detail
}
},
"currentIndexPatternId": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62"
},
"indexpattern": { // duplicate. we have data-sources already
"layers": {},
"currentIndexPatternId": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62"
},
"textBased": { // should not create top-level organization for types.
"layers": {},
"indexPatternRefs": [ // resolve references internall
{
"id": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62",
"title": "kibana_sample_data_logs",
"timeField": "@timestamp"
},
{
"id": "90943e30-9a47-11e8-b64d-95841ca0c247",
"title": "kibana_sample_data_logstsdb",
"timeField": "timestamp"
}
]
]
}
},
"internalReferences": [],
"adHocDataViews": {
"c3eb68ef-478c-4827-9eb1-0bbbc9a45b62": {
"id": "c3eb68ef-478c-4827-9eb1-0bbbc9a45b62",
"title": "kibana_sample_data_logs",
"timeFieldName": "@timestamp",
"sourceFilters": [],
"fieldFormats": {},
"runtimeFieldMap": {},
"fieldAttrs": {},
"allowNoIndex": false,
"name": "kibana_sample_data_logs_ad_hoc",
"allowHidden": false
}
}
}
}
},
"panelIndex": "ad0dff0c-c776-4645-989c-e041dada332a", // internal implementaiton detail
"gridData": { // should have auto-positioning
"i": "ad0dff0c-c776-4645-989c-e041dada332a",
"y": 11,
"x": 0,
"w": 48,
"h": 16
}
}
]
@thomasneirynck
Copy link
Author

a raw lens as exist today.

A suggestion for simplification https://gist.github.com/thomasneirynck/8e857803bf39b5097ae806c9ce9ed112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment