Git Product home page Git Product logo

kibana-vega-vis's Introduction

Vega visualization plugin for Kibana

ATTENTION: This code is mostly unmaintained because Vega plugin is now integrated into core Kibana and has more recent functionality.

Build Vega and Vega-Lite data visualizations into Kibana, either standalone, or on top of a map.

Kibana 6.2 includes this plugin without the leaflet (type=map) support.

Watch a short introduction video

Kibana Vega plugin demo

Quick Demo

  • Use a direct download link from the releases page. Make sure you get the right plugin version that matches your Kibana version, or it won't work!
bin/kibana-plugin install <zip_file_url_from_the_releases_page>

For more info, see Kibana plugin installation instructions

  • In Kibana, choose Visualize, and add Vega visualization.
  • You should immediately see a default graph. If you do not have any time-based data in your ElasticSearch, you can generate some random logstash data using makelogs util (not on production cluster!). Also, make sure your time filter gets enough data in the upper right corner.
  • Try changing mark from line to point, area, bar, circle, square, ... (see docs)
  • Try other logstash examples, including the map example
  • Try other Vega or Vega-Lite visualizations. You may need to make URLs absolute, e.g. replace "url": "data/world-110m.json" with "url": "https://vega.github.io/editor/data/world-110m.json". (see [notes below](#Using Vega and Vega-Lite examples))

Vega with a map

Kibana's default map can be used as a base of the Vega graph. To enable, the graph must specify type=map in the host configuration:

{
  "config": {
    "kibana": {
      "type": "map",

      // Initial map position
      "latitude": 40.7,      // default 0
      "longitude": -74,      // default 0
      "zoom": 7,             // default 2
      "mapStyle": "default", // defaults to "default", but can also be false to disable base layer
      "minZoom": 5,          // default 0
      "maxZoom": 13,         // defaults to the maximum for the given style, or 25 when base is disabled
      "zoomControl": false,  // defaults to true, shows +/- buttons to zoom in/out

      // When false, repaints on each move frame. Makes the graph slower when moving the map
      "delayRepaint": true, // default true
    }
  },
  /* the rest of Vega JSON */
}

This plugin will automatically inject a projection called "projection". Use it to calculate positioning of all geo-aware marks. Additionally, you may use latitude, longitude, and zoom signals. These signals can be used in the graph, or can be updated to modify the positioning of the map.

Querying ElasticSearch

By default, Vega's data element can use embedded and external data with a "url" parameter. Kibana plugin adds support for the direct ElasticSearch queries by overloading the "url" value.

Here is an example of an ES query that gets data from logstash-* index.

{
  "data": [
    {
      "name": "myEsDataSource",
      "url": {
        // Index name
        "index": "logstash-*",

        // Use current dashboard context (e.g. search string),
        // and time range filter with the "@timestamp" field.
        "%context%": true,
        "%timefield%": "@timestamp",

        // TIP: request can be copied from the debug view of another visualizer
        // You can try this query in Kibana Dev tools (hardcode or remove the `%...%` values first)
        "body": {
          // When aggegating, do not return individual documents that match the query
          "size": 0,

          // Data aggegation...
          "aggs": {
            // Name of the aggegation - your Vega graph will use it to parse the results
            "hist": {
              "date_histogram": {
                "field": "@timestamp",
                // interval value will depend on the daterange picker
                // Use an integer to set approximate bucket count
                "interval": {"%autointerval%": true},
                // Make sure we get an entire range, even if it has no data
                "extended_bounds": {
                  "min": {"%timefilter%": "min"},
                  "max": {"%timefilter%": "max"}
                },
                // Use this for linear (e.g. line, area) graphs
                // Without it, empty buckets will not show up
                "min_doc_count": 0
              }
            }
          }
        }
      },

      // This is a useful trick to access just the list of aggregation results named "hist"
      //
      "format": { "property": "aggregations.hist.buckets" },
    }
  ],
  ...
}

As a result, "myEsDataSource" will be a list of objects. Note that "key" is a unix timestamp, and can be used without conversions by the Vega date expressions.

[
    {
      "key_as_string": "2017-06-13T04:00:00.000-04:00",
      "key": 1497340800000,
      "doc_count": 6
    },
    {
      "key_as_string": "2017-06-13T06:00:00.000-04:00",
      "key": 1497348000000,
      "doc_count": 14
    },
    ...
]

Query may be specified with individual range and dashboard context as well. This query is equivalent to "%context%": true, "%timefield%": "@timestamp", except that the timerange is shifted back by 10 minutes:

{
  "data": [
    {
      "name": "myEsDataSource",
      "url": {
        // Index name
        "index": "logstash-*",

        "body": {
          "query": {
            "bool": {
              "must": [
                // This string will be replaced with the auto-generated "MUST" clause
                "%dashboard_context-must_clause%",

                // apply timefilter (upper right corner) to the @timestamp variable
                {
                  "range": {
                    "@timestamp": {
                      // "%timefilter%" will be replaced with the current
                      // values of the time filter (from the upper right corner)
                      "%timefilter%": true

                      // Only work with %timefilter%
                      // Shift the current timefilter by 10 units back
                      "shift": 10,

                      // supports week, day (default), hour, minute, second.
                      "unit": "minute"
                    }
                  }
                }
              ],
              "must_not": [
                // This string will be replaced with the auto-generated "MUST-NOT" clause
                "%dashboard_context-must_not_clause%"
              ]
            }
          },
     ...

The "%timefilter%" can also be used to specify a single min or max value. As shown above, the date_histogram's extended_bounds can be set with two values - min and max. Instead of hardcoding a value, you may use "min": {"%timefilter%": "min"}, which will be replaced with the begining of the current time range. The shift and unit values are also supported. The "interval" can also be set dynamically, depending on the currently picked range: "interval": {"%autointerval%": 10} will try to get about 10-15 datapoints (buckets).

Vega vs Vega-Lite

Vega-Lite is a simplified version of Vega, useful to quickly get started, but has a number of limitations. Vega-Lite is automatically converted into Vega before rendering. Compare logstash-simple_line-vega and logstash-simple_line-vegalite (both use the same ElasticSearch logstash data). You may use this editor to convert Vega-Lite into Vega.

Debugging

Browser Debugging console

Use browser debugging tools (e.g. F12 or Ctrl+Shift+J in Chrome) to inspect the VEGA_DEBUG variable:

  • view - access to the Vega View object. See Vega Debugging Guide on how to inspect data and signals at runtime. For Vega-Lite, VEGA_DEBUG.view.data('source_0') would get the main dataset. For Vega, it uses the data name as defined in your Vega spec.
  • spec - Vega JSON specification after some modifications by this plugin. In case of Vega-Lite, this is the output of the Vega-Lite compiler.
  • vlspec - If this is a Vega-Lite graph, JSON specification of the graph before Vega-Lite compilation.

Data

If you are using ElasticSearch query, make sure your resulting data is what you expected. The easiest way to view it is by using "networking" tab in the browser debugging tools (e.g. F12). Modify the graph slightly so that it makes a search request, and view the response from the server. Another approach is to use Kibana Dev Tools tab - place the index name into the first line: GET <INDEX_NAME>/_search, and add your query as the following lines (just the value of the "query" field)

If you need to share your graph with someone, you may want to copy the raw data response to gist.github.com, possibly with a .json extension, use the [raw] button, and use that url directly in your graph.

Notes

Useful Links

Using Vega and Vega-Lite examples

When using Vega and Vega-Lite examples, you may need to modify the "data" section to use absolute URL. For example, replace "url": "data/world-110m.json" with "url": "https://vega.github.io/editor/data/world-110m.json". Also, regular Vega examples use "autosize": "pad" layout model, whereas Kibana plugin uses fit. Remove all autosize, width, and height values. See sizing and positioning below.

Additional configuration options

These options are specific to this plugin. They control how plugin interprets your Vega spec. Map support has additional configuration options.

{
  "config": {
    "kibana": {
      // Placement of the Vega-defined signal bindings.
      // Can be `left`, `right`, `top`, or `bottom` (default).
      "controlsLocation": "top",
      // Can be `vertical` or `horizontal` (default).
      "controlsDirection": "vertical",
      // If true, hides most of Vega and Vega-Lite warnings
      "hideWarnings": true,
    }
  },
  /* the rest of Vega JSON */
}

Sizing and positioning

Vega and Vega-Lite

By default, Kibana Vega graphs will use autosize = { type: 'fit', contains: 'padding' } layout model for Vega and Vega-Lite graphs. The fit model uses all available space, ignores width and height values, but respects the padding values. You may override this behavior by specifying a different autosize value.

Vega on a map

All Vega and Vega-Lite graphs will ignore autosize, width, height, and padding values, using fit model with zero padding.

Development

See the kibana contributing guide for instructions setting up your development environment. Once you have completed that, use the following npm tasks.

  • npm start

    Start kibana and have it include this plugin

  • npm run build

    Build a distributable archive

  • npm run test:browser

    Run the browser tests in a real web browser

  • npm run test:server

    Run the server tests using mocha

For more information about any of these commands run npm run ${task} -- --help.

kibana-vega-vis's People

Contributors

domoritz avatar ekho avatar nreese avatar nyurik avatar spalger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kibana-vega-vis's Issues

How to work with two aggregations

Hi guys!
Could you help me understand how to work with elasticsearch data?
I'm trying to build binned scatterplot on data from elasticsearch.
I'm gonna use days for X axis and category field for Y axis.
To query data I use two aggregations like so:

          "aggs": {
            "categories": {
              "terms": {
                "field": "category.keyword"
              },
              "aggs": {
                "hist": {
                  "date_histogram": {
                    "field": "@timestamp",
                    "interval": "24h",
                    "time_zone": "Europe/Moscow",
                    "min_doc_count": 1
                  }
                }
              }
            }
          }

And data returned are grouped:

[
  {
    "key": "category 1",
    "buckets": [
      {
         "key": "date1",
         "doc_count": 10
      },
      {
         "key": "date2",
         "doc_count": 10
      }
    ]
  },
  {
    "key": "category 2",
    "buckets": [
      {
         "key": "date1",
         "doc_count": 10
      },
      {
         "key": "date2",
         "doc_count": 10
      }
    ]
  }
]

Every example of vega visualisations uses flattened data. Are there any ways to use such grouped data here?

Kibana 5.6.2 help on request index

Hello,

great job, you help us a lot with that plugin integration.
But we still have a question about how to properly configure the json in order to reach an elasticsearch index for drawing a simple scatter plot. We are stuck can you help us ?
From this example
vega editor 1

We manage to copy and make it run
vega editor 2

But even with your indication on github, we are stuck.
vega editor 3

Do you have any clue ?

Thank you in advance for any kind of help.

Best regards.

Hector

Can not generate parentKey dynamically in stratify transformation

I am creating a tree using stratify transformation. I dont have parentKey within my data but, I want to generate it for each record using two clauses.

parent.step_id = child.step_id-1
parent.@timestamp = immediate previous timestamp of child
I have used lookup transformation here. But it seems to me that lookup transformation does not support two clauses and also it looks for exact value, not within a matching value range. How can I achieve this?

Note: I tried a filter before lookup. But I can not filter with timestamp data. And more over I can not run filter on secondary datasource. If I use it in my primary datasource, primary datasource itself will be modified. Which I dont want.
I have also raised this issue in the vega-transforms repo - vega/vega-transforms#4

Ace editor Ctrl-F doesn't work

Pressing Ctrl-F in the editor causes an error. Seems like ext-searchbox.js cannot be loaded from the /app/ dir (causes 404)

GET https://localhost:5601/raw/app/ext-searchbox.js 
exports.loadScript @ index.js:3264
exports.loadModule @ index.js:3636
exec @ index.js:10532
(anonymous) @ index.js:10289
EventEmitter._emit.EventEmitter._dispatchEvent @ index.js:3317
exec @ index.js:10317
$callKeyboardHandlers @ index.js:4010
onCommandKey @ index.js:4025
onCommandKey @ index.js:11825
normalizeCommandKeys @ index.js:1618
(anonymous) @ index.js:1638

Need this plugin for Kibana 6.2.x

Can you please help to get build to support Kibana 6.2.x? I really need after our recently upgrade from 5.x to 6.2.x upgrade on elasticsearch cluster.

Support Kibana filter expression in Vega code

Hello Team

Firstly, thanks for the awesome widget. This adds great flexibility in creating custom graphs with custom data sources. One clarification we have is, apart from the @timestamp : %timefilter%, is there a possibility to add dashboard context similar to transform_vis - DASHBOARD_CONTEXT? Currently, if we add a vega visual to an existing dashboard, the data is not filtered based on the other graphs filters. Is there any way to achieve the same?

Querying Elastic Search example

I'm trying to create some visualization on Kibana plugin of vega but not able to so with elastic search query example provided. Can you please provide some more example with elastic search query on different vega visualization?

Impossible to tie a search to a vega visual

On vega visual 2.1.4, the search/filter doesn't save with the visual. Impossible to tie a search to a vega visual

To replicate:
Go to vega visual, add a query on the top query box: FIELD:VALUE, save visual. The filter context disappears.

How to revise kibana-vega-vis

As my project request, I may need to revise the vega to fulfill some of our requirements.

I can access and revise vega source code but if I want to use your kibana plugin, I am confused about how to do any modifications.

Could you share me some tutorials for how to revise your code?

Thanks so much.

Data example for source fields

I've been struggling to get Violin Plot working. Is this the correct data query? I am only wanting to pull in the 2 fields.
"data": [ { "name": "iris", "url": { "index": "logstash-hvms-ub-*", "body": { "_source": {"includes": ["physician", "elapse"]} } } } ],

How to visualize bar chart

Hello! I'm new into using Vega, but I succeeded in show a dot graph, I made it to change color and shape using one of the _source fields.
But I have problems into show a stacked bar graph.
Here is the code:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "mark": "bar",
  "data": {
    "url": {
      "%context%": true,
      "%timefield%": "@timestamp",
      "index": "networkstat-*",
      "body": {
        "size": 10000,
        "_source": [
          "@timestamp",
          "ms",
          "status",
          "remotehost"
        ]
      }
    },
    "format": {
      "property": "hits.hits"
    }
  },
  "transform": [
    {
      "calculate": "toDate(datum._source['@timestamp'])",
      "as": "time"
    }
  ],
  "encoding": {
    "x": {
      "timeUnit": "minutes",
      "field": "time",
      "type": "temporal",
      "axis": {"title": "Minutes"}
    },
    "y": {
      "field": "_source.remotehost",
      "aggregate": "count",
      "type": "quantitative"
    },
    "color": {
      "field": "_source.remotehost",
      "type": "nominal",
      "legend": {"title": "Hosts"}
    }
  }
}

I want to show a stacked bar with time series in the X axis and show each host with different color.
But it raises an error: "a._source is undefined" if I change the color field with "time" it works, but not as I wanted.

Boxplot color is overwritten

I intended to make a boxplot based on Elasticsearch data. I added a scale, mapped it to my categorical field and also added a legend based on colors. Despite legend showing the colors and mapping correctly, Box-plots themselves are not colored, instead overwritten with green. I will post my Vega query, results, and the image of the boxplot:

  1. My Vega code
  "$schema": "https://vega.github.io/schema/vega/v3.json",
  "title": "Average delivery delay per meter type",
  "signals": [
    {"name": "plotWidth", "value": 100},
    {"name": "height", "value": 300},
    {
      "name": "tooltip",
      "value": {},
      "on": [
        {"events": "rect:mouseover", "update": "datum"},
        {"events": "rect:mouseout", "update": "{}"}
      ]
    }
  ],
  "data": [
    {
      "name": "results",
      "url": {
        "index": "vee_statistics",
        "%context%": true,
        "%timefield%": "date",
        "body": {
          "size": 0,
          "aggs": {
            "completeness_per_meter_type": {
              "terms": {"field": "meter_type", "size": 10},
              "aggs": {
                "completeness_quantile": {
                  "percentiles": {
                    "field": "avg_delivery_delay",
                    "percents": [25, 50, 75]
                  }
                },
                "min_value": {
                  "min": {"field": "avg_delivery_delay"}
                },
                "max_value": {
                  "max": {"field": "avg_delivery_delay"}
                }
              }
            }
          }
        }
      },
      "format": {
        "property": "aggregations.completeness_per_meter_type.buckets"
      },
      "transform": [
        {
          "type": "formula",
          "expr": "datum.completeness_quantile.values['25.0']",
          "as": "q1"
        },
        {
          "type": "formula",
          "expr": "datum.completeness_quantile.values['50.0']",
          "as": "median"
        },
        {
          "type": "formula",
          "expr": "datum.completeness_quantile.values['75.0']",
          "as": "q3"
        },
        {
          "type": "formula",
          "expr": "datum.min_value.value",
          "as": "min_value"
        },
        {
          "type": "formula",
          "expr": "datum.max_value.value",
          "as": "max_value"
        },
        {
          "type": "fold",
          "fields": [
            "min_value",
            "q1",
            "median",
            "q3",
            "max_value"
          ],
          "as": ["metric", "metricValue"]
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "layout",
      "type": "band",
      "range": "height",
      "domain": {"data": "results", "field": "key"}
    },
    {
      "name": "xscale",
      "type": "linear",
      "range": "width",
      "round": true,
      "domain": {"data": "results", "field": "metricValue"},
      "zero": true,
      "nice": true
    },
    {
      "name": "color",
      "type": "ordinal",
      "domain": {"data": "results", "field": "key"},
      "range": {"scheme": "category20"}
    }
  ],
  "legends":[
    {
      stroke: "color"
      "title": "Meter type"
    }
  ],
  "axes": [
    {
      "orient": "bottom",
      "scale": "xscale",
      "zindex": 1,
      "tickCount": 5,
      "title": "Delay in minutes"
    },
    {
      "orient": "left",
      "scale": "layout",
      "tickCount": 4,
      "zindex": 1,
      "title": "Meter type"
    }
  ],
  "marks": [
    {
      "type": "group",
      "from": {
        "facet": {
          "data": "results",
          "name": "meters",
          "groupby": "key"
        }
      },
      "encode": {
        "enter": {
          "yc": {
            "scale": "layout",
            "field": "key",
            "band": 0.5
          },
          "height": {"signal": "plotWidth"},
          "width": {"signal": "width"}
        }
      },
      "data": [
        {
          "name": "summary",
          "source": "meters",
          "transform": [
            {
              "type": "aggregate",
              "fields": [
                "metricValue",
                "metricValue",
                "metricValue",
                "metricValue",
                "metricValue"
              ],
              "ops": ["min", "q1", "median", "q3", "max"],
              "as": ["min", "q1", "median", "q3", "max"]
            }
          ]
        }
      ],
      "marks": [
        {
          "type": "rect",
          "from": {"data": "summary"},
          "encode": {
            "enter": {
              "fill": {"value": "black"},
              "height": {"value": 1}
            },
            "update": {
              "yc": {
                "signal": "plotWidth/2",
                "offset": -0.5
              },
              "x": {"scale": "xscale", "field": "min"},
              "x2": {"scale": "xscale", "field": "max"}
            }
          }
        },
        {
          "type": "rect",
          "from": {"data": "summary"},
          "encode": {
            "enter": {
              "fill": {"scale": "color", "field": "key"},
              "cornerRadius": {"value": 10},
            
           
              "yc": {"signal": "plotWidth / 2"},
              "height": {"signal": "plotWidth / 2"},
              "x": {"scale": "xscale", "field": "q1"},
              "x2": {"scale": "xscale", "field": "q3"}
            }
          }
        },
        {
          "type": "rect",
          "from": {"data": "summary"},
          "encode": {
            "enter": {
              "fill": {"value": "black"},
              "width": {"value": 2}
            },
            "update": {
              "yc": {"signal": "plotWidth / 2"},
              "height": {"signal": "plotWidth / 2"},
              "x": {"scale": "xscale", "field": "median"}
            }
          }
        },
        {
          "type": "text",
          "encode": {
            "enter": {
              "align": {"value": "center"},
              "baseline": {"value": "bottom"},
              "fill": {"value": "#444"}
            },
            "update": {
              "x": {
                "scale": "xscale",
                "signal": "tooltip.metric",
                "band": 0.5
              },
              "text": {"signal": "tooltip.metricValue"},
              "fillOpacity": [
                {"test": "datum === tooltip", "value": 0},
                {"value": 1}
              ]
            }
          }
        }
      ]
    }
  ]
}

2)My Elasticsearch query results

    "completeness_per_meter_type": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "Landis + Gyr E350",
          "doc_count": 11712,
          "min_value": {
            "value": 0
          },
          "completeness_quantile": {
            "values": {
              "25.0": 0,
              "50.0": 777946.6999389499,
              "75.0": 1636599.4181818184
            }
          },
          "max_value": {
            "value": 2406472
          }
        },
        {
          "key": "Diehl/Hydrometer Hydrus DN 25",
          "doc_count": 7547,
          "min_value": {
            "value": 0
          },
          "completeness_quantile": {
            "values": {
              "25.0": 267769.1359104414,
              "50.0": 960271.0482142858,
              "75.0": 1735614.9509373924
            }
          },
          "max_value": {
            "value": 2408339
          }
        },
        {
          "key": "Inhemeter DTZ 1513i",
          "doc_count": 6199,
          "min_value": {
            "value": 0
          },
          "completeness_quantile": {
            "values": {
              "25.0": 168858.30629629627,
              "50.0": 860171.7062937064,
              "75.0": 1637965.7174185463
            }
          },
          "max_value": {
            "value": 2405565
          }
        },
        {
          "key": "DEMO Meter",
          "doc_count": 790,
          "min_value": {
            "value": 0
          },
          "completeness_quantile": {
            "values": {
              "25.0": 7.000000000000001,
              "50.0": 10,
              "75.0": 33.63333333333333
            }
          },
          "max_value": {
            "value": 912912.75
          }
        }
      ]
    }
  }
  1. My visualization
    image

Pasting over full text fails the first time

Repo: Select entire Vega text with Ctrl+A, and paste another Vega markup. It will fail. Repeating the steps will succeed.

Error: End of input while parsing an object (missing '}') at line 116,1 >>> ...
    at error (http://localhost:5601/bundles/kibana.bundle.js?v=8467:266:2578)
    at object (http://localhost:5601/bundles/kibana.bundle.js?v=8467:266:7805)
    at legacyRootValue (http://localhost:5601/bundles/kibana.bundle.js?v=8467:266:8636)
    at Object.module.exports [as parse] (http://localhost:5601/bundles/kibana.bundle.js?v=8467:266:9253)
    at VegaVisController.<anonymous> (http://localhost:5601/bundles/kibana.bundle.js?v=8467:213:20300)
    at tryCatch (http://localhost:5601/bundles/commons.bundle.js?v=8467:52:27644)
    at Generator._invoke (http://localhost:5601/bundles/commons.bundle.js?v=8467:52:29719)
    at Generator.prototype.(anonymous function) [as next] (http://localhost:5601/bundles/commons.bundle.js?v=8467:52:27928)
    at step (http://localhost:5601/bundles/kibana.bundle.js?v=8467:213:18961)
    at http://localhost:5601/bundles/kibana.bundle.js?v=8467:213:19165

Vega-lite 2.3.0

Hello!
Are you planning to continue updating the plugin or as it is included in kibana it will be released with newer versions of it?

I have some issues related to the version of vega-lite, that are working with their editor but not with kibana. It is possible to upgrade the version of vega-lite of the plugin without having to update all? Something like drag and drop the vega-lite new version on the same plugin folder?

Also, thank you very much for creating that plugin that makes my life happier!

Newbie Issue with Line Chart

Hi,

I am trying to plot a Basic line chart using the examples and some modification w.r.t data from ES

{
  "$schema": "https://vega.github.io/schema/vega/v3.0.json",
  "width": 500,
  "height": 200,
  "padding": 5,

  "signals": [
    {
      "name": "interpolate",
      "value": "linear",
      "bind": {
        "input": "select",
        "options": [
          "basis",
          "cardinal",
          "catmull-rom",
          "linear",
          "monotone",
          "natural",
          "step",
          "step-after",
          "step-before"
        ]
      }
    }
  ],

 "data": [
    {
      "name": "table",
      "url": {
        "index": "scadatcp-*",
        "%context_query%": "date_and_time",
        "body": {
          "size": 0,
          "aggs": {
            "hist": {
              "date_histogram": {
                "field": "date_and_time",
                "interval": "2h",
                "time_zone": "Asia/Dubai",
                "min_doc_count": 1
              }
            }
          }
        }
      },
      "format": {
        "type": "json",
        "property": "aggregations.hist.buckets"
      }
    }
  ],

  "scales": [
    {
      "name": "x",
      "type": "point",
      "range": "width",
      "domain": {"data": "table", "field": "date_and_time"}
    },
    {
      "name": "y",
      "type": "linear",
      "range": "height",
      "nice": true,
      "zero": true,
      "domain": {"data": "table", "field": "b4"}
    },
    {
      "name": "color",
      "type": "ordinal",
      "range": "category",
      "domain": {"data": "table", "field": "b5"}
    }
  ],

  "axes": [
    {"orient": "bottom", "scale": "x"},
    {"orient": "left", "scale": "y"}
  ],

  "marks": [
    {
      "type": "group",
      "from": {
        "facet": {
          "name": "series",
          "data": "table",
          "groupby": "b5"
        }
      },
      "marks": [
        {
          "type": "line",
          "from": {"data": "series"},
          "encode": {
            "enter": {
              "x": {"scale": "x", "field": "date_and_time"},
              "y": {"scale": "y", "field": "b4"},
              "stroke": {"scale": "color", "field": "b5"},
              "strokeWidth": {"value": 2}
            },
            "update": {
              "interpolate": {"signal": "interpolate"},
              "fillOpacity": {"value": 1}
            },
            "hover": {
              "fillOpacity": {"value": 0.5}
            }
          }
        }
      ]
    }
  ]
}

Only getting undefined as one of the axis, please help

How can I install vega plugin in Kibana 5.6.1

HI Guys,

I am new in Kibana. I want to know that how can I configure vega in Kibana 5.6.1 in ubuntu 16.04.
There is not an option display for vega graphs under Other in Visulization tab in Kibana 5.6.1

Kindly help me to install vega plugin in kibana 5.6.1
I am using elastic search 5.6.1
Kibana 5.6.1

regards,
Adil kadiyawala

License?

I'm sorry if I missed it, but I couldn't find licensing information for kibana-vega-vis. Could you please include the ususal LICENSE.md (or similar) file, and/or licensing information in source code files (I checked some of them randomly, but I couldn't find any).

Making aggregations useful for tree diagram

Hi there,

I have data in this form:

"aggregations": {
    "InfluencerName": {
      "doc_count_error_upper_bound": 839,
      "sum_other_doc_count": 35818,
      "buckets": [
        {
          "key": "Aubrey Graham (Drake)",
          "doc_count": 4474,
          "brand": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 1342,
            "buckets": [
              {
                "key": "Nike",
                "doc_count": 1250
              },
              {
                "key": "Moncler",
                "doc_count": 1120
              },
              {
                "key": "OVO",
                "doc_count": 762
              }
            ]
          }
        },
        {
          "key": "Ariana Grande",
          "doc_count": 3958,
          "brand": {
            "doc_count_error_upper_bound": 119,
            "sum_other_doc_count": 2670,
            "buckets": [
              {
                "key": "La Perla",
                "doc_count": 485
              },
              {
                "key": "Alex Woo",
                "doc_count": 428
              },
              {
                "key": "Levi's",
                "doc_count": 375
              }
            ]
          }
        }
      ]
    }
  }

And I'm trying to create a treemap with this data. I can't figure out how to make this usable for the tree graph. I've tried a couple different transforms, but it just seems like it's not working.

I feel like my vega code makes sense, but it just isn't extracting the children of each aggregation correctly. I feel like its potentially because vega is expecting each document to be standalone and not pre aggregated by ES. But I'm not sure. Should I use the hits instead of the aggregations? Any insight would help! I looked at the "flatten" transform but I get an error that the "flatten" type is unknown by Kibana. Don't know why that's happening either.

Thanks!

{
  "$schema": "https://vega.github.io/schema/vega/v3.json",
  "width": 960,
  "height": 500,
  "padding": 2.5,
  "autosize": "none",

  "signals": [
    {
      "name": "layout", "value": "squarify",
      "bind": {
        "input": "select",
        "options": [
          "squarify",
          "binary",
          "slicedice"
        ]
      }
    },
    {
      "name": "aspectRatio", "value": 1.6,
      "bind": {"input": "range", "min": 0.2, "max": 5, "step": 0.1}
    }
  ],

  "data": [
    {
      "name": "tree",
      "url": {
    //  %context%: true
     // %timefield%: @timestamp
      
      index: production
      body : {
          aggs: {
            InfluencerName: {
              terms: {
                field: personname.keyword
              },
              aggs: {
                brand: {
                  terms: {
                    field: brandname.keyword
                   
                  }
                }
              }
            }
          }
        }
      }
       # We only need a specific array of values from the response
       format: {property: "aggregations.InfluencerName.buckets" }
      "transform": [
        // {
        //   "type": "stratify",
        //   "key": "brand.bucket",
        //   "parentKey": "key"
        // },
        {
          "type": "nest",
          "key": "key",
          "keys": ["key", "brand.buckets.key"],
          # "generate": true
          
        },
        {
          "type": "treemap",
          "field": "doc_count",
          "sort": {"field": "doc_count"},
          "round": true,
          "method": {"signal": "layout"},
          "ratio": {"signal": "aspectRatio"},
          "size": [{"signal": "width"}, {"signal": "height"}]
        }
      ] 
    },
    {
      "name": "nodes",
      "source": "tree"
      "transform": [{ "type": "filter", "expr": "datum.children" }]
    },
    {
      "name": "leaves",
      "source": "tree",
      "transform": [{ "type": "filter", "expr": "!datum.children" }]
    }
  ],

  "scales": [
    {
      "name": "color",
      "type": "ordinal",
      "range": [
        "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d",
        "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476",
        "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc",
        "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9"
      ]
    },
    {
      "name": "size",
      "type": "ordinal",
      "domain": [0, 1, 2, 3],
      "range": [256, 28, 20, 14]
    },
    {
      "name": "opacity",
      "type": "ordinal",
      "domain": [0, 1, 2, 3],
      "range": [0.15, 0.5, 0.8, 1.0]
    }
  ],

  "marks": [
    {
      "type": "rect",
      "from": {"data": "nodes"},
      "interactive": false,
      "encode": {
        "enter": {
          "fill": {"scale": "color", "field": "key"}
        },
        "update": {
          "x": {"field": "x0"},
          "y": {"field": "y0"},
          "x2": {"field": "x1"},
          "y2": {"field": "y1"}
        }
      }
    },
    {
      "type": "rect",
      "from": {"data": "leaves"},
      "encode": {
        "enter": {
          "stroke": {"value": "#fff"}
        },
        "update": {
          "x": {"field": "x0"},
          "y": {"field": "y0"},
          "x2": {"field": "x1"},
          "y2": {"field": "y1"},
           "fill": {"value": "transparent"}
        },
        "hover": {
          "fill": {"value": "green"}
        }
      }
    },
    {
      "type": "text",
      "from": {"data": "nodes"},
      "interactive": false,
      "encode": {
        "enter": {
          "font": {"value": "Helvetica Neue, Arial"},
          "align": {"value": "center"},
          "baseline": {"value": "middle"},
          "fill": {"value": "#000"},
          "text": {"field": "key"},
          "fontSize": {"scale": "size", "field": "depth"},
          "fillOpacity": {"scale": "opacity", "field": "depth"}
        },
        "update": {
          "x": {"signal": "0.5 * (datum.x0 + datum.x1)"},
          "y": {"signal": "0.5 * (datum.y0 + datum.y1)"}
        }
      }
    }
  ]
}

Different results on Vega editor and on Vega Kibana plugin

I constructed a visualization on the Vega editor and then copied the code to the Vega plugin (plugin version 1.2.0 on Kibana 6.2.3); the result is different (and incorrect -- as far as the Vega editor result is considered correct!). The visualization uses external data, not fetched from ES, so it's the same data on both occasions.

In fact, the Kibana plugin issues an error message "Cannot read property 'tuple' of undefined", so something is clearly wrong. Also after some time (or a screen refresh, I have not been able to locate exactly the instance) another error "Cannot read property 'stamp' of undefined" appears.

Any suggestions on how to find the cause?

I could only share the code and data privately, if requested.

There is some heavy processing of the raw data involved (the data is in the form I will get it from ES); I use the following transforms: flatten, project, lookup, filter, joinaggregate.

Thanks in advance.

EDIT: I now see that on the Developer's Console of Vega Editor the same errors appear, but somehow there the visualization is constructed as expected; so I will investigate it a little more.

Make editor panel "hidable"

Users should be able to hide the left (code) panel, not just resize it. Enabling CSS class doesn't fully work, possibly due to the flow.

Incorrect Kibana version in plugin error

Hey,

I love the plugin! I am however running into a little issue.

Plugin installation was unsuccessful due to error "Incorrect Kibana version in plugin [vega_vis]. Expected [5.5.1]; found [5.5.0]"

I have followed the instructions, so:

  • Downloaded Kibana 5.5.1 from https://www.elastic.co/downloads/kibana
  • Ran the following command to install Vega:
    • ./bin/kibana-plugin install https://github.com/nyurik/kibana-vega-vis/releases/download/0.1.1/vega_vis-0.1.1.zip

And then I get the following output:

~/kibana-5.5.1-darwin-x86_64
>> ./bin/kibana-plugin install https://github.com/nyurik/kibana-vega-vis/releases/download/0.1.1/vega_vis-0.1.1.zip
Attempting to transfer from https://github.com/nyurik/kibana-vega-vis/releases/download/0.1.1/vega_vis-0.1.1.zip
Transferring 19867293 bytes....................
Transfer complete
Retrieving metadata from plugin archive
Extracting plugin archive
Extraction complete
Plugin installation was unsuccessful due to error "Incorrect Kibana version in plugin [vega_vis]. Expected [5.5.1]; found [5.5.0]"

To my understanding, I am running 5.5.1 as that is the latest major version from Elastic. Any help would be greatly appreciated!

Make Singnals usable in queries.

Hi,
My goal is to have two queries, over two separate indices, where the second one depends on the results of the first one.

I can extract the necessary values from the first query and store them in a signal, but I cannot actually use any signals inside the 'url' object.

Is there a chance this feature will be added, or is present but I am using it wrong?

Auto-size graph

Hello again @nyurik!
Please, can you help me to discover why is kibana and vega-vis not adjusting the size of the visualization?
Here is what I am viewing:
vega-vis
As you can see, a square is showing and not resizing when I minimize the visualization.

Thank you very much!

Merge all map signals into one

I suspect it will be more efficient for the two-way binding to have a single object {lat, lon, zoom} rather than three individual signals. Also need an example of a graph that moves the map on an event.

To support install the plugin for kibana 6.1.0

I tried to install the plugin in my environment, but can't install the plugin for kibana 6.1.0. It's better to have this support. Thx a lot.

root@bpmtap-2:/home/software/kibana-6.1.0-linux-x86_64# bin/kibana-plugin install https://github.com/nyurik/kibana-vega-vis/releases/download/v0.5.1/vega_vis-0.5.1--for-Kibana-6.0.1.zip
Attempting to transfer from https://github.com/nyurik/kibana-vega-vis/releases/download/v0.5.1/vega_vis-0.5.1--for-Kibana-6.0.1.zip
Transferring 28444904 bytes....................
Transfer complete
Retrieving metadata from plugin archive
Extracting plugin archive
Extraction complete
Plugin installation was unsuccessful due to error "Incorrect Kibana version in plugin [vega_vis]. Expected [6.1.0]; found [6.0.1]"

Installing Kibana-vega-vis plugin errors out.

Hi,

I am trying to install Kibana-vega-vis plugin and it is throwing following error,

Plugin installation was unsuccessful due to error "Optimizations failure.

    ERROR in ./plugins/vega_vis/public/vega_vis.controller.js
    Module not found: Error: Cannot resolve 'file' or 'directory' /usr/share/kibana/src/ui/public/resize_checker in /usr/share/kibana/plugins/vega_vis/public
     @ ./plugins/vega_vis/public/vega_vis.controller.js 16:24-52

Can someone please help solve this issue?

Thanks

Do not regenerate graph on auto-refreshing

Vega graph should auto-refresh its data. The simple way is to regenerate the whole graph every time new data becomes available. The more efficient ("proper") way would be to implement JS observables pattern - so when Vega requests Elastic Search data, return an object with .subscribe() instead of .then(). Vega will use that .subscribe function to provide a callback. This also requires a bit of upstream modification of the Vega's data loader code -- vega/vega#893

Some graphs are not resizing properly

For example try this with the latest release

  "$schema": "https://vega.github.io/schema/vega/v3.0.json",
  "width": 500,
  "height": 400,
  "padding": 5,
  "autosize": "pad",
  "signals": [
    {
      "name": "count", "value": 10,
      "bind": {"input": "select", "options": [1, 5, 10, 20]}
    },
    {
      "name": "points", "value": true,
      "bind": {"input": "checkbox"}
    }
  ],

  "data": [
    {
      "name": "source",
      "url": "https://vega.github.io/vega/data/cars.json",
      "transform": [
        {
          "type": "filter",
          "expr": "datum['Horsepower'] != null && datum['Miles_per_Gallon'] != null"
        }
      ]
    },
    {
      "name": "contours",
      "source": "source",
      "transform": [
        {
          "type": "contour",
          "x": {"expr": "scale('x', datum.Horsepower)"},
          "y": {"expr": "scale('y', datum.Miles_per_Gallon)"},
          "size": [{"signal": "width"}, {"signal": "height"}],
          "count": {"signal": "count"}
        }
      ]
    }
  ],

  "scales": [
    {
      "name": "x",
      "type": "linear",
      "round": true,
      "nice": true,
      "zero": false,
      "domain": {"data": "source", "field": "Horsepower"},
      "range": "width"
    },
    {
      "name": "y",
      "type": "linear",
      "round": true,
      "nice": true,
      "zero": false,
      "domain": {"data": "source", "field": "Miles_per_Gallon"},
      "range": "height"
    },
    {
      "name": "color",
      "type": "sequential",
      "zero": true,
      "domain": {"data": "contours", "field": "value"},
      "range": "heatmap"
    }
  ],

  "axes": [
    {
      "scale": "x",
      "grid": true,
      "domain": false,
      "orient": "bottom",
      "title": "Horsepower"
    },
    {
      "scale": "y",
      "grid": true,
      "domain": false,
      "orient": "left",
      "title": "Miles_per_Gallon"
    }
  ],

  "legends": [{
    "fill": "color",
    "type": "gradient"
  }],

  "marks": [
    {
      "type": "path",
      "from": {"data": "contours"},
      "encode": {
        "enter": {
          "stroke": {"value": "#888"},
          "strokeWidth": {"value": 1},
          "fill": {"scale": "color", "field": "value"},
          "fillOpacity": {"value": 0.35}
        }
      },
      "transform": [
        { "type": "geopath", "field": "datum" }
      ]
    },
    {
      "name": "marks",
      "type": "symbol",
      "from": {"data": "source"},
      "encode": {
        "update": {
          "x": {"scale": "x", "field": "Horsepower"},
          "y": {"scale": "y", "field": "Miles_per_Gallon"},
          "size": {"value": 4},
          "fill": [
            {"test": "points", "value": "black"},
            {"value": "transparent"}
          ]
        }
      }
    }
  ],

  "config": {
    "range": {
      "heatmap": {"scheme": "greenblue"}
    }
  }
}```

Use HJSON syntax highlighting

Ace editor needs to use HJSON instead of JSON syntax formatting. HJSON support has been added recently to the core Ace editor, so it may need to be added to core Kibana, or a custom version bound to this plugin.

logstash-simple_line-vegalite.json example fails

I'm using Kibana 5.5.2 with vega_vis-0.3.1--for-Kibana-5.5.2.

The first thing I tried was to display the 'logstash-simple_line-vegalite.json' example. This fails with this error in the console:

commons.bundle.js?v=15443:38 TypeError: Cannot convert undefined or null to object
at Function.keys ()
at parse (kibana.bundle.js?v=15443:310)
at read (kibana.bundle.js?v=15443:317)
at View.ingest$1 [as ingest] (kibana.bundle.js?v=15443:310)
at kibana.bundle.js?v=15443:310
at processQueue (commons.bundle.js?v=15443:38)
at commons.bundle.js?v=15443:38
at Scope.$eval (commons.bundle.js?v=15443:39)
at Scope.$digest (commons.bundle.js?v=15443:39)
at Scope.$apply (commons.bundle.js?v=15443:39)

If I remove the line '"name": "table",' from the data specification in the file then it works OK. I guess vegalite has a single unnamed data item and shouldn't have the table name specified.

It would be good to fix the example file and maybe have a vega-lite-style ES data query in the README.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.