RousselTMLEARNING

Observability

Logstash: inputs and outputs

Written version of the video lessons: common inputs (beats, file, tcp/udp, http, kafka, jdbc) and outputs (elasticsearch with data streams, file, s3, kafka, stdout), with their key options.

1. Inputs #

Receiving data.

Common inputs #

Sources, Logstash and destinations.
InputUseKey option
beats / elastic_agentreceive Beats and Elastic Agentport => 5044, ssl_enabled
fileread local filespath, start_position, sincedb_path
tcp / udp / syslognetwork streamsport, codec
httpreceive webhooksport, codec => json
kafkaconsume topicsbootstrap_servers, topics, group_id
jdbcquery an SQL databasestatement, schedule, tracking_column
input {
  beats { port => 5044 }
  file  { path => "/var/log/app/*.log" start_position => "beginning" }
  jdbc  {
    jdbc_connection_string => "jdbc:postgresql://db:5432/app"
    jdbc_user => "lecture"
    jdbc_driver_class => "org.postgresql.Driver"
    schedule => "*/5 * * * *"
    statement => "SELECT * FROM commandes WHERE maj > :sql_last_value"
    use_column_value => true
    tracking_column => "maj"
    tracking_column_type => "timestamp"
  }
}
Good to know: The codec decodes data at input (json, multiline, plain) or encodes it at output.

2. Outputs #

Sending data.

The elasticsearch output #

output {
  elasticsearch {
    hosts => ["https://es1:9200", "https://es2:9200"]
    api_key => "${ES_API_KEY}"
    ssl_certificate_authorities => ["/etc/logstash/ca.crt"]
    data_stream => true
    data_stream_type => "logs"
    data_stream_dataset => "app"
    data_stream_namespace => "prod"
  }
}
Good practice: Write to data streams (logs-app-prod) rather than dated indices: rollover, ILM retention and index templates are then handled by Elasticsearch.

Other outputs #

OutputUse
stdout { codec => rubydebug }debugging
filelocal copy
s3cheap long-term archiving
kafkafeed other consumers
pipelinesend to another Logstash pipeline
Common mistake: Putting the Elasticsearch password in clear text in the pipeline file: use the keystore (bin/logstash-keystore add ES_API_KEY) and reference the value with ${ES_API_KEY}.

Related articles

Logstash: role, pipeline concept and installation

Written version of the video lessons: what Logstash is for, how a pipeline works (inputs, filters, outputs, q…

Logstash: filters, grok and dissect

Written version of the video lessons: essential filters (mutate, date, json, kv, drop), the grok plugin and i…

Logstash: managing plugins and adopting Elastic Common Schema (ECS)

Written version of the video lessons: list, install, update and bundle Logstash plugins offline; understand E…

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!