1. Lens #
The visualization editor.
Principle #
Lens suggests the right visualization when you drag a field: a time histogram for @timestamp, top values for a text field, a metric for a number. You can then change the type (bars, areas, table, gauge, heat map, pie chart) without starting over.
| Need | Lens visualization |
|---|---|
| Volume over time | Stacked bars or areas on @timestamp |
| Top N | Sorted horizontal bars |
| Key indicator | Metric (with trend) |
| Distribution | Histogram on a numeric field |
| Geographic distribution | Maps |
| Formula | count(kql='http.response.status_code >= 500') / count() |
Good practice: The Lens formula lets you compute ratios (error rate, cache hit rate) without precomputing in Elasticsearch.
2. Dashboards #
Interactive and shareable.
Good layouts #
- At the top: key indicators (Metric); in the middle: trends; at the bottom: detail tables.
- Add controls (lists of services, environments) to filter the whole dashboard.
- Use drilldowns to go from a panel to Discover or to another filtered dashboard.
- Organize dashboards by space (Spaces) and by tags.
3. Saved objects as code #
Export, import, versioning.
API #
# Exporter tous les dashboards et leurs dépendances
curl -s -X POST localhost:5601/api/saved_objects/_export -u elastic:$PASS \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' \
-d '{"type": ["dashboard"], "includeReferencesDeep": true}' > dashboards.ndjson
# Importer dans un autre Kibana (ou un autre espace)
curl -s -X POST 'localhost:5601/s/equipe-web/api/saved_objects/_import?overwrite=true' -u elastic:$PASS \
-H 'kbn-xsrf: true' -F file=@dashboards.ndjsonVersioning the .ndjson file in Git and importing it from CI lets you promote a dashboard from staging to production and restore it after a mistake.
Good to know: The /s/<space> prefix targets a Kibana space; without a prefix, it is the default space.