Prometheus docker container using Terraform

35 views
Skip to first unread message

Andrew Hooker

unread,
Oct 15, 2019, 10:55:30 AM10/15/19
to Prometheus Users
I have the standard prometheus container working via docker using the terraform docker container provider. This is running great with persistant storage, prometheus.yml etc.

I am trying to understand how within the terraform configuration you add the commandline flags to set items like retention etc. I can find no where that it is possible to set these settings types in a config file and it seems they must be set on the command line when the prometheus service is started?

Has anyone got this working and can give me a pointer to help me?

Many Thanks

Stuart Clark

unread,
Oct 15, 2019, 10:59:10 AM10/15/19
to Andrew Hooker, Prometheus Users
As you mentioned some items like the retention period are set via the command line rather than prometheus.yml, so these would be added to the Terraform configuration of the container.

Is there a specific problem you are encountering?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Andrew Hooker

unread,
Oct 15, 2019, 11:09:05 AM10/15/19
to Prometheus Users
Well I guess the question is how to do this in Terraform itself. I do not see a way to apend commandline flags. I was hoping the someone in the community may have encountered this issue previously.

The specific problem I have crosses three boundaries. It is not specific to Prometheus and is in fact a config using the docker supported provider in Terraform.

So I could raise this in multiple places :)

Stuart Clark

unread,
Oct 15, 2019, 12:06:25 PM10/15/19
to Andrew Hooker, Prometheus Users
On 2019-10-15 16:09, Andrew Hooker wrote:
> Well I guess the question is how to do this in Terraform itself. I do
> not see a way to apend commandline flags. I was hoping the someone in
> the community may have encountered this issue previously.
>
> The specific problem I have crosses three boundaries. It is not
> specific to Prometheus and is in fact a config using the docker
> supported provider in Terraform.
>
> So I could raise this in multiple places :)
>

So in Terraform you'd set the "command" option in the docker_container:

command - (Optional, list of strings) The command to use to start the
container. For example, to run /usr/bin/myprogram -f baz.conf set the
command to be ["/usr/bin/myprogram", "-f", "baz.conf"].

The default command line for the Prometheus image is as follows:

[ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \

"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

So you'd want to add those plus any extra entries you need.

> On Tuesday, 15 October 2019 15:59:10 UTC+1, Stuart Clark wrote:
>
>> As you mentioned some items like the retention period are set via
>> the command line rather than prometheus.yml, so these would be added
>> to the Terraform configuration of the container.
>>
>> Is there a specific problem you are encountering?
>>
>> On 15 October 2019 15:55:30 BST, Andrew Hooker
>> <and...@shrubwood.net> wrote:
>>
>>> I have the standard prometheus container working via docker using
>>> the terraform docker container provider. This is running great
>>> with persistant storage, prometheus.yml etc.
>>>
>>> I am trying to understand how within the terraform configuration
>>> you add the commandline flags to set items like retention etc. I
>>> can find no where that it is possible to set these settings types
>>> in a config file and it seems they must be set on the command line
>>> when the prometheus service is started?
>>>
>>> Has anyone got this working and can give me a pointer to help me?
>>>
>>> Many Thanks
>>
>> --
>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prometheus-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/76a58095-c3d6-414d-859b-3f8732dd7fbc%40googlegroups.com
> [1].
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/prometheus-users/76a58095-c3d6-414d-859b-3f8732dd7fbc%40googlegroups.com?utm_medium=email&utm_source=footer

--
Stuart Clark

Andrew Hooker

unread,
Oct 15, 2019, 5:34:40 PM10/15/19
to Prometheus Users
Thanks.

I turned out to be on the right lines but needed all the flags included (not just the specific ones I wanted to change from default)

Again thanks for the assistance!

Andrew

Mr C0ns1st3nt

unread,
Jul 13, 2020, 11:58:57 AM7/13/20
to Prometheus Users
I wrote an article which may help you and hopefully explains my journey to a working Prometheus:

Reply all
Reply to author
Forward
0 new messages