How to add token refresh to outputs.http in Telegraf

Hi all!

I’ve been working with Telegraf for a little over a year now and love it!
We use it to send our time series data to Wavefront over TCP through our pipeline.
Recently we added a proxy in the GCP using the CloudRun service.

The way that the connection is made however is no longer TCP and instead http.
The downside for this though is that you have to go through a few hoops to get your token and it only lasts an hour.
The process is as follows:
You use your Google provided JSON private key and service account to hit a url
That returns an Google access token
You then use that access token to then get a second token that you then can use to make a POST request to the CloudRun URL that will forward the metrics onto the proxy.
Additionally the maximum expiration length of the token is one hour.

I’ve tested outputs.http with the token and http headers and found it worked correctly but only for one hour.

Is there an already established method for sending metrics using the above process and if not any suggestions on how to add a new plugin that supports these extra features using outputs.http as a base?
I already have the code needed to do all the handshaking, I just need to add the functionality into the plugin, along with a timer like ticker := time.NewTicker(60 * time.Minute) so that it will trigger the handshaking process again.

Thoughts?

Thanks in advance!!

Hi,
I was able to get something written up but I get the following error:
cloudrun.go:14:2: use of internal package github.com/influxdata/telegraf/internal not allowed when I compile.
Note this doesn’t happen when I haven’t added the plugin to the all.go file.
Thoughts?