RousselTMLEARNING

Observability

OpenSearch Dashboards, alerting and observability

Explore data in OpenSearch Dashboards, create alert monitors and discover Trace Analytics, Event Analytics and Anomaly Detection.

1. OpenSearch Dashboards #

Exploring and visualizing.

First steps #

  1. Create an index pattern (for example logs-app-*) choosing the time field.
  2. In Discover, search and filter your documents.
  3. Build visualizations, then assemble them into a dashboard.
  4. Open Dev Tools to try your queries.
Menus may vary by version. This part describes the console from the documentation: only the APIs of this course were run.

2. Alerting #

Monitors and triggers.

A monitor through the API #

A monitor runs a query at a regular interval; a trigger evaluates a condition on the result; an action notifies through a channel.

curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X POST https://localhost:9200/_plugins/_alerting/monitors -d '{
  "type": "monitor",
  "name": "erreurs_logs",
  "monitor_type": "query_level_monitor",
  "enabled": true,
  "schedule": {"period": {"interval": 1, "unit": "MINUTES"}},
  "inputs": [{"search": {"indices": ["logs-app-*"],
    "query": {"size": 0, "query": {"term": {"level": "error"}}}}}],
  "triggers": [{"name": "au_moins_une_erreur", "severity": "2",
    "condition": {"script": {"source": "ctx.results[0].hits.total.value > 0", "lang": "painless"}},
    "actions": []}]
}'

Add an action once the channel is created in Notifications.

3. Observability #

Logs, traces and anomalies.

What the platform offers #

FeaturePurpose
Trace AnalyticsRequest paths and service map, from the indexes fed by Data Prepper
Event AnalyticsExplore events with PPL
Anomaly DetectionAutomatically detect deviations on a metric
Security AnalyticsDetection rules on security logs

4. Dashboards in practice #

Visualizations, saved objects and reports.

The path #

Building a dashboard
VisualizationFor
Line, area (TSVB, Line)a trend over time: errors per minute, p95 latency
Barscompare groups: errors per service
Metric, gaugea key figure: current error rate
Data tablea ranking: 10 slowest URLs
Mappositions: client IP geolocation
Vegaa custom, declarative visualization

Versioning saved objects #

Dashboards, visualizations and index patterns export as NDJSON through the console API (port 5601). The osd-xsrf header is required.

curl -sk -u "$AUTH" -X POST http://localhost:5601/api/saved_objects/_export \
  -H 'osd-xsrf: true' -H 'Content-Type: application/json' \
  -d '{"type": ["dashboard", "visualization", "index-pattern"], "includeReferencesDeep": true}' > objets.ndjson

curl -sk -u "$AUTH" -X POST 'http://localhost:5601/api/saved_objects/_import?overwrite=true' \
  -H 'osd-xsrf: true' -F file=@objets.ndjson
Best practice : Store objets.ndjson in Git and import it on each deployment: your dashboards no longer depend on a lost click.

Reports and notebooks #

  • Reporting: PDF, PNG or CSV export of a dashboard, on demand or scheduled.
  • Notebooks: an investigation document mixing text, PPL/SQL queries and visualizations.
  • Workspaces and tenants: separate objects per team.

Commands to know #

Commands to know
  • GET http://localhost:5601/api/status : console status
  • POST /api/saved_objects/_export : export saved objects
  • POST /api/saved_objects/_import : import objects
  • GET _plugins/_alerting/monitors/_search : list monitors

Related articles

The OpenSearch cluster in depth: nodes, shards and replication

Understanding how an OpenSearch cluster works inside: node roles, cluster manager election, shard allocation,…

Full-text search in OpenSearch: analyzers and relevance

Mastering full-text search: inverted index, analyzers (including French), the _analyze API, match, multi_matc…

Advanced aggregations, PPL and SQL in OpenSearch

Analyzing data in OpenSearch: bucket, metric and pipeline aggregations, date histograms, approximate cardinal…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!