Guides
...
Usage Metering
Ingestion Options

Elastic Logstash

5min

Meter Ingestion via Logstash

Integrating metering data into Amberflo can be done with open source Logstash. The integration uses the Logstash S3 output plugin and writes the metering records to the Amberflo S3 bucket. You can use Logstash's rich language for parsing the metering data out of your logs/repositories. Logstash can extract data from files, Elasticsearch, JDBC, S3, MongoDB and other systems using various input plugins. https://www.elastic.co/guide/en/logstash/current/input-plugins.html

Example - Logstash configuration

In the example below we will share a sample Logstash configuration that reads log lines from a file and writes the relevant metering records to Amberflo's S3 bucket. We will tail new files locally from /Users/demoaccount/input/* the sample file format log line 1 log line 2 myMeter 2 myCustomerId amberflo_meter log line 3

Logstash will read any new file and transform them using the mutate logic into metering records. In this example we ignore any line without the string: amberflo_meter. We splits based on the space character " ", and treat the meterApiName, meterValue, cusomterId as the first, second and third object accordingly.

Ruby


The resulting file (meter record) will be:

JSON


JDBC source

You can use the Logstash JDBC source to extract the metering info from your repository. https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html

Ruby


Elasticsearch input

You can use the Elasticsearch input if you have metering data in your logs. An example input plugin looks like:

Ruby




Updated 05 Nov 2024
Did this page help you?