Add curl command in graylog start-up

Hello Team,

Graylog 4.1.5

I am trying to add one curl commanf for my changes to work with graylog at startup in below docker entry point

graylog() {

exec “${JAVA_HOME}/bin/java”
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
“${GRAYLOG_HOME}/graylog.jar”
server
-f “${GRAYLOG_HOME}/data/config/graylog.conf”
}

Even tried to use nohup and exec $@ but it doesn’t allow curl to execute and
If it’s allow my container goes in crashloop error,

Added before it won’t work since graylog is not started
Added in graylog function it gives crashloop error
Added after graylog function it doesn’t execute curl command,

Any help here would be appreciated,

Regards,
SAM

Hello,

I might be able to help.
Some more information on what you see and the commands your executing would be helpful.
To better help you, help us please take a look here.

Thank you @gsmith

We have graylog as a docker container

We start its services as mentioned in docker entry point as below

graylog() {

exec “${JAVA_HOME}/bin/java”
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
“${GRAYLOG_HOME}/graylog.jar”
server
-f “${GRAYLOG_HOME}/data/config/graylog.conf”
}

What I have tried

SCENARIO1:
If I put my curl before above graylog function it won’t work since graylog is not up

curl something

graylog() {

exec “${JAVA_HOME}/bin/java”
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
“${GRAYLOG_HOME}/graylog.jar”
server
-f “${GRAYLOG_HOME}/data/config/graylog.conf”
}

SCENARIO2:
If I put my curl command within graylog function it works but it crashes container

graylog() {

exec “${JAVA_HOME}/bin/java”
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
“${GRAYLOG_HOME}/graylog.jar”
server
-f “${GRAYLOG_HOME}/data/config/graylog.conf” &
Sleep 10
curl something
}

I guess it’s due to exec same happens with nohup as well

SCENARIO3
If I put my curl after graylog function it doesn’t even execute due to exec

graylog() {

exec “${JAVA_HOME}/bin/java”
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
“${GRAYLOG_HOME}/graylog.jar”
server
-f “${GRAYLOG_HOME}/data/config/graylog.conf”
}

curl something


What I am trying here I want to execute curl command when graylog is ready so it should start with few properties enable.

I hope I am able to explain my use case

Regards
Sam

Correct me if I’m wrong but your trying to add a curl command to something like this?

docker run --name mongo -d mongo:4.2
docker run --name elasticsearch \    
    -e "http.host=0.0.0.0" \    
    -e "discovery.type=single-node" \    
    -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \    
    -d docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
docker run --name graylog --link mongo --link elasticsearch \    
    -p 9000:9000 -p 12201:12201 -p 1514:1514 \    
    -e GRAYLOG_HTTP_EXTERNAL_URI="http://127.0.0.1:9000/" \    
    -d graylog/graylog:4.2

Could you explain in greater detail about this? Like what properties are you not wanting to start?

What I know is that most , if not all community members use Curl for Elasticsearch to modify or simply get info.

I am referring this and we are pushing images to openshift via Jenkins build,

Please refer this

This is how graylog service gets started in container,

All I want to run my curl command when graylog is up and functional, to achieve that I tried several methods explained above,

I don’t want to do anything special I just want to adjust my curl command somewhere so that when I access graylog the properties should be enabled by default,

Manually I am able to do so, all I want is to adjust curl with graylog startup currently command gets successful but container gets crashloop due to exec thing I am suspecting.

I am enabling trusted header authentication to true with user.

Regards,
Sam

@samurai29

Unfortunately I’m not knowledgeable in either openshift or Jenkins and as for the Docker file I haven’t see that done before. I am curious if you get it to work thou.
Sorry I cant give you a direct answer about modifying your Docker installation. Maybe someone else here has done it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.