logstash-plugins / logstash-input-google_pubsub

Logstash input for pulling events from Google Pub/Sub service
Apache License 2.0
19 stars 33 forks source link

Get message attributes #43

Closed alefcarlos closed 5 years ago

alefcarlos commented 5 years ago

I'm trying to get message attributes, but the value is not returning...

input {
    google_pubsub {
        # Your GCP project id (name)
        project_id => "dotz-dev-219021"

        # The topic name below is currently hard-coded in the plugin. You
        # must first create this topic by hand and ensure you are exporting
        # logging to this pubsub topic.
        topic => "dharma-monitoring"

        # The subscription name is customizeable. The plugin will attempt to
        # create the subscription (but use the hard-coded topic name above).
        subscription => "logstash-sub"

        # If you are running logstash within GCE, it will use
        # Application Default Credentials and use GCE's metadata
        # service to fetch tokens.  However, if you are running logstash
        # outside of GCE, you will need to specify the service account's
        # JSON key file below.
        json_key_file => "/usr/share/logstash/key.json"

        # Should the plugin attempt to create the subscription on startup?
        # This is not recommended for security reasons but may be useful in
        # some cases.
        create_subscription => true

        codec => "json"
    }
}

filter {
  mutate {
    add_field => { "serviceName" => "%{[@metadata][pubsub_message][attributes][serviceName]}" }
    add_field => { "messageId" => "%{[@metadata][pubsub_message][messageId]}" }
  }
}

Returned values are:

Am I missing something ?

alefcarlos commented 5 years ago

I found the problem.

This config include_metadata => true MUST BE configured.

It is cool to update this doc