Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

error after terraform configuration #127

Open
Luubosi opened this issue Jul 3, 2019 · 13 comments
Open

error after terraform configuration #127

Luubosi opened this issue Jul 3, 2019 · 13 comments
Labels
documentation question Further information is requested

Comments

@Luubosi
Copy link
Contributor

Luubosi commented Jul 3, 2019

hi, please advice.
I have these errors after application terraform configuration and restart graylog docker container. With manual configuration after restart graylog is ok.
Please, did you test terraform code to docker imlementation? After restart is it working?
Thanks

2019-07-03 15:15:34,840 INFO : org.graylog2.shared.buffers.ProcessBuffer - Initialized ProcessBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:35,094 INFO : org.graylog2.shared.buffers.ProcessBuffer - Initialized ProcessBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:36,191 INFO : org.graylog2.shared.buffers.ProcessBuffer - Initialized ProcessBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:36,246 INFO : org.graylog2.shared.buffers.ProcessBuffer - Initialized ProcessBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:36,297 INFO : org.mongodb.driver.connection - Opened connection [connectionId{localValue:3, serverValue:75}] to mongo:27017
2019-07-03 15:15:36,316 INFO : org.graylog2.shared.buffers.ProcessBuffer - Initialized ProcessBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:36,367 INFO : org.graylog2.buffers.OutputBuffer - Initialized OutputBuffer with ring size <65536> and wait strategy <BlockingWaitStrategy>.
2019-07-03 15:15:36,390 ERROR: org.graylog2.bootstrap.CmdLineTool - Guice error (more detail on log level debug): Error injecting constructor, java.lang.NullPointerException
2019-07-03 15:15:36,390 ERROR: org.graylog2.bootstrap.CmdLineTool - Guice error (more detail on log level debug): Error injecting constructor, java.lang.NullPointerException
2019-07-03 15:15:36,391 ERROR: org.graylog2.bootstrap.CmdLineTool - Guice error (more detail on log level debug): Error injecting constructor, java.lang.NullPointerException
2019-07-03 15:15:36,391 ERROR: org.graylog2.bootstrap.CmdLineTool - Guice error (more detail on log level debug): Error injecting constructor, java.lang.NullPointerException
Exception in thread "main" com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.NullPointerException
  at org.graylog2.shared.buffers.ProcessBuffer.<init>(ProcessBuffer.java:59)
  at org.graylog2.shared.bindings.GenericBindings.configure(GenericBindings.java:60)
  while locating org.graylog2.shared.buffers.ProcessBuffer
    for the 2nd parameter of org.graylog2.periodical.ThrottleStateUpdaterThread.<init>(ThrottleStateUpdaterThread.java:76)
  while locating org.graylog2.periodical.ThrottleStateUpdaterThread
  while locating org.graylog2.plugin.periodical.Periodical annotated with @com.google.inject.internal.Element(setName=,uniqueId=354, type=MULTIBINDER, keyType=)
  while locating java.util.Set<org.graylog2.plugin.periodical.Periodical>
    for the 3rd parameter of org.graylog2.shared.initializers.PeriodicalsService.<init>(PeriodicalsService.java:45)
  at org.graylog2.shared.initializers.PeriodicalsService.class(PeriodicalsService.java:36)
  while locating org.graylog2.shared.initializers.PeriodicalsService
  while locating com.google.common.util.concurrent.Service annotated with @com.google.inject.internal.Element(setName=,uniqueId=7, type=MULTIBINDER, keyType=)
  while locating java.util.Set<com.google.common.util.concurrent.Service>
    for field at org.graylog2.shared.bindings.providers.ServiceManagerProvider.services(ServiceManagerProvider.java:34)
  while locating org.graylog2.shared.bindings.providers.ServiceManagerProvider
  at org.graylog2.shared.bindings.GenericBindings.configure(GenericBindings.java:64)
  while locating com.google.common.util.concurrent.ServiceManager
Caused by: java.lang.NullPointerException
        at org.graylog2.streams.StreamRuleMatcherFactory.build(StreamRuleMatcherFactory.java:31)
        at org.graylog2.streams.StreamRouterEngine$Rule.<init>(StreamRouterEngine.java:278)
        at org.graylog2.streams.StreamRouterEngine.<init>(StreamRouterEngine.java:98)
        at org.graylog2.streams.StreamRouterEngine$$FastClassByGuice$$c6190f39.newInstance(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
        at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:836)
        at com.sun.proxy.$Proxy41.create(Unknown Source)
        at org.graylog2.streams.StreamRouter$StreamRouterEngineUpdater.getNewEngine(StreamRouter.java:136)
        at org.graylog2.streams.StreamRouter$StreamRouterEngineUpdater.access$000(StreamRouter.java:102)
        at org.graylog2.streams.StreamRouter.<init>(StreamRouter.java:62)
        at org.graylog2.streams.StreamRouter$$FastClassByGuice$$f9455617.newInstance(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
        at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
        at com.google.inject.internal.RealMultibinder$RealMultibinderProvider.doProvision(RealMultibinder.java:198)
        at com.google.inject.internal.RealMultibinder$RealMultibinderProvider.doProvision(RealMultibinder.java:151)
        at com.google.inject.internal.InternalProviderInstanceBindingImpl$Factory.get(InternalProviderInstanceBindingImpl.java:113)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
        at com.google.inject.i
```ntern
@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Jul 3, 2019

Hello.
Please tell us how to reproduce.

  • terraform version
  • terraform-provider-graylog version
  • Graylog version
  • terraform configuration files
  • How to setup Graylog. For example, if you use Docker Compose, please share docker-compose.yml

And it is the Graylog's problem.
Unfortunately, I think the Graylog API's validation isn't adequate and we can break Graylog with Graylog API.
You should contact the Graylog community (ex. https://community.graylog.org ).

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Jul 3, 2019

terraform simply calls Graylog API.
If Graylog breaks when we call the Graylog API, it is not the client problem but the Graylog's problem.

@Luubosi
Copy link
Contributor Author

Luubosi commented Jul 3, 2019

for reproduce:
Terraform v0.12.2
terraform-provider-graylog_v3.3.0_windows_amd64
graylog/graylog:3.0.2

version: '2'
networks:
  default:
    external:
      name: dockergraylog_default
services:
# MongoDB: https://hub.docker.com/_/mongo/
  mongodb:
    image: mongo:3
    container_name: mongodb
    restart: always
    volumes:
      - /opt/mongodb:/data/db
    ports:
      - 27017:27017

  # Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.0
    container_name: elasticsearch
    restart: always
    ports:
      - 9200:9200
    environment:
      - http.host=0.0.0.0
      - transport.host=localhost
      - network.host=0.0.0.0
      - bootstrap.memory_lock=false
      - xpack.security.enabled=false
      - "ES_JAVA_OPTS=-Xms3g -Xmx3g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 3g
    volumes:
      - /opt/elasticsearch_graylog/data:/usr/share/elasticsearch/data

  # Graylog: https://hub.docker.com/r/graylog/graylo
  # https://docs.graylog.org/en/3.0/pages/installation/docker.html
  graylog:
    image: graylog/graylog:3.0.2
    container_name: graylog
    restart: always
    volumes:
      - /opt/graylog_etc/journal:/usr/share/graylog/data/journal
      - /opt/graylog_etc/server:/etc/graylog/server
      - /opt/graylog_etc/plugin:/usr/share/graylog/plugin
    environment:
      - GRAYLOG_IS_MASTER=true
      - GRAYLOG_ROOT_TIMEZONE=Europe/Bratislava
      - GRAYLOG_ELASTICSEARCH_SHARDS=1
      - GRAYLOG_ELASTICSEARCH_REPLICAS=0
      - GRAYLOG_MESSAGE_JOURNAL_MAX_SIZE=3gb
      - GRAYLOG_SERVER_JAVA_OPTS=-Xms3g -Xmx3g -XX:NewRatio=1 -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow
      - GRAYLOG_PASSWORD_SECRET=secretsecretsecretsecretsecret
      # Password: echo -n PASSWORD | shasum -a 256
      - GRAYLOG_ROOT_PASSWORD_SHA2=Password-output
      - GRAYLOG_HTTP_PUBLISH_URI=http://fqdn:9000/
      - GRAYLOG_HTTP_EXTERNAL_URI=http://fqdn:9000/

    links:
      - mongodb:mongo
      - elasticsearch
    depends_on:
      - mongodb
      - elasticsearch
    ports:
      # Graylog web interface and REST API
      - 9000:9000
      #- 443:443
      # INPUT_TDAGENT
      - 20800:20800
      # INPUT_SYSLOG_TCP
      - 20517:20517

terraform code, there is complete configuration, i will investigate if some source is problem.
for example, to create input - gelf tcp/udp, syslog tcp/udp.

@Luubosi
Copy link
Contributor Author

Luubosi commented Jul 7, 2019

Hi,
please add to this docs page "description" as required argument.
For example, test from gui, it is not possible to create stream without description.
thanks

https://github.com/suzuki-shunsuke/go-graylog/blob/master/terraform/docs/stream.md

@Luubosi
Copy link
Contributor Author

Luubosi commented Jul 7, 2019

Hi,
please edit docs, bool values should be in ""
for example

resource "graylog_stream" "stream01" {
title = "Stream_${lookup(var.input5, "title")}"
description = "Stream_${lookup(var.input5, "title")}"
index_set_id = "${graylog_index_set.index_set1.id}"
depends_on = [graylog_index_set.index_set1]
disabled = "false"
remove_matches_from_default_stream = "true"
matching_type = "AND"
is_default = "false"
}

@suzuki-shunsuke
Copy link
Owner

Thank you for your feedback!

Although I don't know whether it is also correct on Terraform v0.12,
I found the documentation about Terraform v0.11.

https://www.terraform.io/docs/configuration-0-11/variables.html#booleans

Although Terraform can automatically convert between boolean and string values,
there are some subtle implications of these conversions that should be completely understood when using boolean values with input variables.

It is recommended for now to specify boolean values for variables as the strings "true" and "false", to avoid some caveats in the conversion process.
A future version of Terraform will properly support boolean values and so relying on the current behavior could result in backwards-incompatibilities at that time.

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Jul 8, 2019

please add to this docs page "description" as required argument.
For example, test from gui, it is not possible to create stream without description.

Thank you for your feedback!
I checked the behavior on Graylog v3.0.2.
Although the description is required at GUI, it is optional at REST API.

POST /streams

request body

{
      "title": "test",
      "index_set_id": "5cdf8c8ed497d2000f0a3bc9"
 }

response

response code: 201

response body

{
  "stream_id": "5d2289bcd497d2000f72109d"
}

created stream

{
      "id": "5d2289bcd497d2000f72109d",
      "creator_user_id": "admin",
      "outputs": [],
      "matching_type": "AND",
      "description": null,
      "created_at": "2019-07-08T00:09:32.347Z",
      "disabled": true,
      "rules": [],
      "alert_conditions": [],
      "alert_receivers": {
        "emails": [],
        "users": []
      },
      "title": "test",
      "content_pack": null,
      "remove_matches_from_default_stream": false,
      "index_set_id": "5cdf8c8ed497d2000f0a3bc9",
      "is_default": false
    }

The description of the created stream is null.
Is it related to the error when Graylog is restarted?
I restarted Graylog but it seems Graylog doesn't output error logs.

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Jul 8, 2019

I add the parameter description to the document as an optional parameter.
Thank you.
#136

@suzuki-shunsuke suzuki-shunsuke added the question Further information is requested label Jul 8, 2019
@Luubosi
Copy link
Contributor Author

Luubosi commented Jul 8, 2019

Hi Suzuki,
Is it related to the error when Graylog is restarted?
yes, this all is related to error when graylog is restarted.

for streams, this configuration is for me correct:
resource "graylog_stream" "stream01" {
title = "Stream_${lookup(var.input5, "title")}"
description = "Stream_${lookup(var.input5, "title")}"
index_set_id = "${graylog_index_set.index_set1.id}"
depends_on = [graylog_index_set.index_set1]
disabled = "false"
remove_matches_from_default_stream = "true"
matching_type = "AND"
is_default = "false"
}

to add description was not solution, but to add disabled = "false" and is_default = "false" in "" was solution.

The same error i have by stream rule :(, others resources are ok.
resource "graylog_stream_rule" "stream01-1" {
field = "field_input"
value = "${lookup(var.input5, "title")}"
depends_on = [graylog_stream.stream01]
stream_id = "${graylog_stream.stream01.id}"
description = "test stream rule1"
type = 0
inverted = false
}
I have tested inverted = "false", but no ok.
Could you please test, or clarify this / as ID?
Thanks for your work/project.

@Luubosi
Copy link
Contributor Author

Luubosi commented Jul 8, 2019

Hi,
this is correct.
resource "graylog_stream_rule" "stream01895" {
field = "field_input"
value = "testTEST"
#na ktory stream aplikujeme dane pravidlo
depends_on = [graylog_stream.stream01]
stream_id = "${graylog_stream.stream01.id}"
description = "test stream rule1"
type = 1
inverted = "false"
}

type = 1 for "must match exactly"
The value 0 causes this error:
please test, and edit this page https://github.com/suzuki-shunsuke/go-graylog/blob/master/terraform/docs/stream_rule.md

10) Error injecting constructor, java.lang.NullPointerException
  at org.graylog2.shared.buffers.ProcessBuffer.<init>(ProcessBuffer.java:59)
  at org.graylog2.shared.bindings.GenericBindings.configure(GenericBindings.java:60)
  while locating org.graylog2.shared.buffers.ProcessBuffer
    for the 1st parameter of org.graylog2.buffers.Buffers.<init>(Buffers.java:43)
  while locating org.graylog2.buffers.Buffers
    for the 1st parameter of org.graylog2.initializers.BufferSynchronizerService.<init>(BufferSynchronizerService.java:51)
  at org.graylog2.initializers.BufferSynchronizerService.class(BufferSynchronizerService.java:39)
  while locating org.graylog2.initializers.BufferSynchronizerService
    for the 2nd parameter of org.graylog2.initializers.OutputSetupService.<init>(OutputSetupService.java:46)
  at org.graylog2.initializers.OutputSetupService.class(OutputSetupService.java:38)
  while locating org.graylog2.initializers.OutputSetupService
Caused by: java.lang.NullPointerException (same stack trace as error #7)
10 errors
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:543)
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
        at com.google.inject.Guice.createInjector(Guice.java:87)
        at org.graylog2.shared.bindings.GuiceInjectorHolder.createInjector(GuiceInjectorHolder.java:34)
        at org.graylog2.bootstrap.CmdLineTool.setupInjector(CmdLineTool.java:379)
        at org.graylog2.bootstrap.CmdLineTool.run(CmdLineTool.java:194)
        at org.graylog2.bootstrap.Main.main(Main.java:50)

suzuki-shunsuke added a commit that referenced this issue Jul 9, 2019
remove boolean from examples because the treat of boolean in the
terraform configuration is ambiguous and it is out of scope of this provider's document.

#127 (comment)
@suzuki-shunsuke
Copy link
Owner

I have fixed the document.
#138

@dzirg44
Copy link

dzirg44 commented Sep 4, 2019

@suzuki-shunsuke according to the official API we don't have 'ID - 0'
only these values were allowed.

[
  {
    "id": 1,
    "name": "EXACT",
    "short_desc": "match exactly",
    "long_desc": "match exactly"
  },
  {
    "id": 2,
    "name": "REGEX",
    "short_desc": "match regular expression",
    "long_desc": "match regular expression"
  },
  {
    "id": 3,
    "name": "GREATER",
    "short_desc": "greater than",
    "long_desc": "be greater than"
  },
  {
    "id": 4,
    "name": "SMALLER",
    "short_desc": "smaller than",
    "long_desc": "be smaller than"
  },
  {
    "id": 5,
    "name": "PRESENCE",
    "short_desc": "field presence",
    "long_desc": "be present"
  },
  {
    "id": 6,
    "name": "CONTAINS",
    "short_desc": "contain",
    "long_desc": "contain"
  },
  {
    "id": 7,
    "name": "ALWAYS_MATCH",
    "short_desc": "always match",
    "long_desc": "always match"
  }
]

maybe we should use "name" instead of 'id' ? For me it's a little bit strange that API allows us creating 'broken' resources. I have made the issue in the graylog bugtracker
Graylog2/graylog2-server#6382.
sorry for my b English

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Sep 6, 2019

@dzirg44
Sorry for the late reply and thank you for your feedback.

I have fixed the document.
#164

maybe we should use "name" instead of 'id' ?

I agree.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants