Flux Custom Functions and Packages

We have built a growing set of custom flux functions and starting to find that it would be great to be able to put all these functions into a custom package so that we could share them across queries and avoid duplication.

Something like:

import “org.funcs”

… use org.funcs.customfunc()

Any idea if we might be able to do that with the current 2.0 version?

Thank you,
Brian

1 Like

@bknoth Yes! You can submit custom packages to the Flux project. Eventually we will have a Flux package repo that you can publish to and pull from, but we’re not quite there yet. For now, you can contribute your package in the stdlib/contrib directory. Here are some details: https://github.com/influxdata/flux/tree/master/stdlib/contrib.

1 Like

@scott Thanks for the answer. That sounds like a good solution for general purpose custom functions that someone might want to share publicly. I was thinking more along the lines that we have custom functions that are very specific to the types of data that we work with and are not general purpose. I was hoping there might be a way to create packages inside a deployed InfluxDB that could be seen from within flux, without needing to update the flux source code origin and re-build. Maybe even something like an “include” statement which could bring in shared flux code.

Brian

1 Like

That would be really cool! Maybe that’s something that could be added on the InfluxDB side.

@bknoth More details on plans for user packages (and local reusable Flux code) are available in a recent Flux Github issue.

1 Like

Hello @bknoth and @mkarlesky ,
This might be useful:

Thank you, @Anaisdg. Unfortunately, no. The functionality the blog post describes regards publicly available packages when we’re inquiring about private packages. The blog post explains how to create Flux packages (written in Go) shared with the community at large. We’re asking about creating private Flux packages (in Flux) so that we can reuse our own code in multiple Flux queries without duplication. Said code would not be appropriate for public contribution. @nathaniel addressed our request perfectly in the Github issue I linked to yesterday.

If you’re an OSS user, you can still use the approach above to build user packages locally (you don’t have to contribute them :slight_smile: ) But I understand your point. Thank you for linking the issue. I just wanted to include the link here in case it benefits anyone who visits this thread.

1 Like

I found the answer to a problem that has been bothering me for a long time. Thanks for sharing this topic!

1 Like

@RicardoBenham,
Out of curiosity, what was your problem?