|
| 1 | +[role="xpack"] |
| 2 | +[[lens]] |
| 3 | +== Lens |
| 4 | + |
| 5 | +beta[] |
| 6 | + |
| 7 | +*Lens* provides you with a simple and fast way to create visualizations from your Elasticsearch data. With Lens, you can: |
| 8 | + |
| 9 | +* Quickly build visualizations by dragging and dropping data fields. |
| 10 | + |
| 11 | +* Understand your data with a summary view on each field. |
| 12 | + |
| 13 | +* Easily change the visualization type by selecting the automatically generated visualization suggestions. |
| 14 | + |
| 15 | +* Save your visualization for use in a dashboard. |
| 16 | + |
| 17 | +[float] |
| 18 | +[[drag-drop]] |
| 19 | +=== Drag and drop |
| 20 | + |
| 21 | +The data panel in the left column shows the data fields for the selected time period. When |
| 22 | +you drag a field from the data panel, Lens highlights where you can drop that field. The first time you drag a data field, |
| 23 | +you'll see two places highlighted in green: |
| 24 | + |
| 25 | +* The visualization builder pane |
| 26 | + |
| 27 | +* The *X-axis* or *Y-axis* fields in the right column |
| 28 | + |
| 29 | +You can incorporate many fields into your visualization, and Lens uses heuristics to decide how |
| 30 | +to apply each one to the visualization. |
| 31 | + |
| 32 | +[role="screenshot"] |
| 33 | +image::images/lens_drag_drop.gif[] |
| 34 | + |
| 35 | +TIP: Drag-and-drop capabilities are available only when Lens knows how to use the data. You can still customize |
| 36 | +your visualization if Lens is unable to make a suggestion. |
| 37 | + |
| 38 | +[float] |
| 39 | +[[apply-lens-filters]] |
| 40 | +==== Find the right data |
| 41 | + |
| 42 | +Lens shows you fields based on the <<index-patterns, index patterns>> you have defined in |
| 43 | +{kib}, and the current time range. When you change the index pattern or time filter, |
| 44 | +the list of fields are updated. |
| 45 | + |
| 46 | +To narrow the list of fields you see in the left panel, you can: |
| 47 | + |
| 48 | +* Enter the field name in *Search field names*. |
| 49 | + |
| 50 | +* Click *Filter by type*, then select the filter. You can also select *Only show fields with data* |
| 51 | +to show the full list of fields from the index pattern. |
| 52 | + |
| 53 | +[float] |
| 54 | +[[view-data-summaries]] |
| 55 | +==== Data summaries |
| 56 | + |
| 57 | +To help you decide exactly the data you want to display, get a quick summary of each data field. |
| 58 | +The summary shows the distribution of values in the time range. |
| 59 | + |
| 60 | +To view the data information, navigate to a data field, then click *i*. |
| 61 | + |
| 62 | +[role="screenshot"] |
| 63 | +image::images/lens_data_info.gif[] |
| 64 | + |
| 65 | +[float] |
| 66 | +[[change-the-visualization-type]] |
| 67 | +==== Change the visualization type |
| 68 | + |
| 69 | +With Lens, you are no longer required to build each visualization from scratch. Lens allows |
| 70 | +you to switch between any supported chart type at any time. Lens also provides |
| 71 | +suggestions, which are shortcuts to alternate visualizations based on the data you have. |
| 72 | + |
| 73 | +You can switch between suggestions without losing your previous state: |
| 74 | + |
| 75 | +[role="screenshot"] |
| 76 | +image::images/lens_suggestions.gif[] |
| 77 | + |
| 78 | +If you want to switch to a chart type that is not suggested, click the chart type in the |
| 79 | +top right, then select a chart type. When there is an exclamation point (!) |
| 80 | +next to a chart type, Lens is unable to transfer your current data, but |
| 81 | +still allows you to make the change. |
| 82 | + |
| 83 | +[float] |
| 84 | +[[customize-operation]] |
| 85 | +==== Customize the data for your visualization |
| 86 | + |
| 87 | +Lens allows some customizations of the data for each visualization. |
| 88 | + |
| 89 | +. Change the index pattern. |
| 90 | + |
| 91 | +.. In the left column, click the index pattern name. |
| 92 | + |
| 93 | +.. Select the new index pattern. |
| 94 | ++ |
| 95 | +If there is a match, Lens displays the new data. All fields that do not match the index pattern are removed. |
| 96 | + |
| 97 | +. Change the data field options, such as the aggregation or label. |
| 98 | + |
| 99 | +.. Click *Drop a field here* or the field name in the right column. |
| 100 | + |
| 101 | +.. Change the options that appear depending on the type of field. |
| 102 | + |
| 103 | +[float] |
| 104 | +[[layers]] |
| 105 | +==== Layers in bar, line, and area charts |
| 106 | + |
| 107 | +The bar, line, and area charts allow you to layer two different series. To add a layer, click *+*. |
| 108 | + |
| 109 | +To remove a layer, click the chart icon next to the index name: |
| 110 | + |
| 111 | +[role="screenshot"] |
| 112 | +image::images/lens_remove_layer.png[] |
| 113 | + |
| 114 | +[float] |
| 115 | +[[lens-tutorial]] |
| 116 | +=== Lens tutorial |
| 117 | + |
| 118 | +Ready to create your own visualization with Lens? Use the following tutorial to create a visualization that |
| 119 | +lets you compare sales over time. |
| 120 | + |
| 121 | +[float] |
| 122 | +[[lens-before-begin]] |
| 123 | +==== Before you begin |
| 124 | + |
| 125 | +To start, you'll need to add the <<add-sample-data, sample ecommerce data>>. |
| 126 | + |
| 127 | +[float] |
| 128 | +==== Build the visualization |
| 129 | + |
| 130 | +Drag and drop your data onto the visualization builder pane. |
| 131 | + |
| 132 | +. Open *Visualize*, then click *Create visualization*. |
| 133 | + |
| 134 | +. On the *New Visualization* window, click *Lens*. |
| 135 | + |
| 136 | +. In the left column, select the *kibana_sample_data_ecommerce* index. |
| 137 | + |
| 138 | +. Click image:images/time-filter-calendar.png[], then click *Last 7 days*. The list of data fields are updated. |
| 139 | + |
| 140 | +. Drag and drop the *taxful_total_price* data field to the visualization builder pane. |
| 141 | ++ |
| 142 | +[role="screenshot"] |
| 143 | +image::images/lens_tutorial_1.png[Lens tutorial] |
| 144 | + |
| 145 | +Lens has taken your intent to see *taxful_total_price* and added in the *order_date* field to show |
| 146 | +average order prices over time. |
| 147 | + |
| 148 | +To break down your data, drag the *category.keyword* field to the visualization builder pane. Lens |
| 149 | +understands that you want to show the top categories and compare them across the dates, |
| 150 | +and creates a chart that compares the sales for each of the top 3 categories: |
| 151 | + |
| 152 | +[role="screenshot"] |
| 153 | +image::images/lens_tutorial_2.png[Lens tutorial] |
| 154 | + |
| 155 | +[float] |
| 156 | +[[customize-lens-visualization]] |
| 157 | +==== Further customization |
| 158 | + |
| 159 | +Customize your visualization to look exactly how you want. |
| 160 | + |
| 161 | +. In the right column, click *Average of taxful_total_price*. |
| 162 | + |
| 163 | +.. Change the *Label* to `Sales`, or a name that you prefer for the data. |
| 164 | + |
| 165 | +. Click *Top values of category.keyword*. |
| 166 | + |
| 167 | +.. Increase *Number of values* to `10`. The visualization updates in the background to show there are only |
| 168 | +six available categories. |
| 169 | + |
| 170 | +. Look at the suggestions. None of them show an area chart, but for sales data, a stacked area chart |
| 171 | +might make sense. To switch the chart type: |
| 172 | + |
| 173 | +.. Click *Stacked bar chart* in the right column. |
| 174 | + |
| 175 | +.. Click *Stacked area*. |
| 176 | ++ |
| 177 | +[role="screenshot"] |
| 178 | +image::images/lens_tutorial_3.png[Lens tutorial] |
| 179 | + |
| 180 | +[float] |
| 181 | +[[lens-tutorial-next-steps]] |
| 182 | +==== Next steps |
| 183 | + |
| 184 | +Now that you've created your visualization in Lens, you can add it to a Dashboard. |
| 185 | + |
| 186 | +For more information, see <<dashboard,Dashboard>>. |
0 commit comments