Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Template management fails when AWS IAM authentication is used #124

Closed
akhritonenkov opened this issue Feb 9, 2022 · 2 comments · Fixed by #146
Closed

[BUG] Template management fails when AWS IAM authentication is used #124

akhritonenkov opened this issue Feb 9, 2022 · 2 comments · Fixed by #146
Labels
bug Something isn't working untriaged

Comments

@akhritonenkov
Copy link

Describe the bug
Template management fails to install a template when AWS IAM authentication is used. According to the log it fails to construct URL when signing the AWS request.

To Reproduce
Steps to reproduce the behavior:

  1. Configure logstash output as follows:
    opensearch {
    auth_type => {
    type => "aws_iam"
    region => "us-west-2"
    }
    id => "Write_Events_To_Elasticsearch"
    hosts => ["https://open_search_instance.us-west-2.es.amazonaws.com"]
    manage_template => true
    template_overwrite => true
    template => "/usr/share/logstash/files/events.json"
    template_name => "events_101"
    sniffing => false
    index => "events_101-%{+YYYY-MM-dd}"
    }
    (in my case it takes credentials from the ~/.aws/credentials file, hence they are not specified inside auth_type)
  2. Run the pipeline and observe the exception.

Expected behavior
Template installed without an error.

Plugins
kafka input
opensearch output

Screenshots
N/A

Host/Environment (please complete the following information):

  • OS: Linux
  • Version 5.4.172-90.336.amzn2.x86_64 x86_64

Additional context
Excerpt from the log:

[2022-02-09T18:26:47,670][INFO ][logstash.outputs.opensearch][main] Installing OpenSearch template {:name=>"events_101"}
[2022-02-09T18:26:47,672][ERROR][logstash.outputs.opensearch][main] Failed to install template {
:message=>"bad component(expected absolute path component): _template/events_101",
:exception=>URI::InvalidComponentError,
:backtrace=>[
"uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/generic.rb:771:in check_path'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/generic.rb:819:in path='",
"uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/generic.rb:193:in initialize'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/generic.rb:138:in build'",
"uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/http.rb:62:in build'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/manticore_adapter.rb:176:in sign_aws_request'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/manticore_adapter.rb:154:in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/pool.rb:270:in perform_request_to_url'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/pool.rb:257:in block in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/pool.rb:346:in with_connection'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/pool.rb:256:in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client/pool.rb:264:in block in Pool'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client.rb:388:in template_put'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/http_client.rb:82:in template_install'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/template_manager.rb:37:in install'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch/template_manager.rb:25:in install_template'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch.rb:412:in install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch.rb:247:in finish_register'",
"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/outputs/opensearch.rb:224:in block in register'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-opensearch-1.2.0-java/lib/logstash/plugin_mixins/opensearch/common.rb:83:in block in after_successful_connection'"
]}

sample template events.json:
{
"order": 0,
"index_patterns": [
"events_101*"
],
"settings": {
"index": {
"codec": "best_compression",
"mapping": {
"ignore_malformed": "true"
},
"refresh_interval": "30s",
"analysis": {
"normalizer": {
"lowercase_normalizer": {
"filter": [
"lowercase"
],
"type": "custom",
"char_filter": []
}
}
},
"number_of_shards": "5",
"number_of_replicas": "1"
}
},
"mappings": {
"_doc": {
"_size": {
"enabled": true
},
"_field_names": {
"enabled": false
},
"dynamic": false,
"properties": {
"id": {
"norms": false,
"index": false,
"type": "keyword",
"doc_values": false
},
"status": {
"normalizer": "lowercase_normalizer",
"type": "keyword"
}
}
}
},
"aliases": {
"events_101": {},
"event_101": {}
}
}

@efesenmaiersf
Copy link

efesenmaiersf commented Feb 12, 2022

This looks to be the same issue as awslabs/logstash-output-amazon_es#101

@VijayanB - Proposed a fix in #125, but it would need to run tests, etc.

@VijayanB
Copy link
Member

Thank you @efesenmaiersf for sharing the work around. check here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
3 participants