-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prometheus on gokrazy: how to include web UI assets? #208
Comments
Hey @Syphdias 👋 I split this question into a separate issue because it’s not really related to the userguide. Does prometheus not use go:embed for its assets? Could/should it? |
Hopefully it will be, if I write it down after I understood it.
I’m quite the beginner on go, so this will be a learning opportunity. I figured since you explicitly mentioned prometheus in your recent GPN talk, you already run it on gokrazy and just didn’t get to writing it down. Sounds like you didn’t. It took me quite a while to figure out why I got an error when just adding upstream and why the precompiled binary through breakglass worked. When using I have no idea if it should use go:embed. Yes, it already does but can I trigger this from the go build command somehow? PS: Something of note might be that the go module version is different from the Prometheus version. Not sure if that matters in any way. |
I run the node exporter and blackbox exporter regularly. I ran the prometheus server (built using make) for a few days for an event network, but I don’t do that on a permanent basis. Sorry that the nuance of “how to deploy” wasn’t included in my talk for the prometheus example. I mainly wanted to point out that it’s possible, i.e. that prometheus runs in a gokrazy environment once you get it installed. I’ll be more careful regarding phrasing in the next iteration.
I see. In Go, generation of any sort (typically with the I think this would need a discussion upstream in prometheus. Haven’t checked the issues if buildability with the go tool was already discussed, though, so that would be the next step. |
I really enjoyed your talk. How to deploy in detail was not the focus of the talk of the talk after all. And to be fair. I did get prometheus to run on gokrazy in two different ways even. One was to use the precompiled binary, the other was what you did prior to your talk. I was wondering how it should be done though. I found prometheus/prometheus#7517 which refers to the mailing list post from 2020 where someone explains that "the new React UI requires some separate build steps that are not Go-based, and the result of that is not checked in (because it's hard to make completely reproducible builds that wouldn't create diffs every time the React UI is built)." I guess it is unlikely that they will change their build process for our convenience. If the could use So I see two approaches to deal with prometheus (and possibly other go written tools that require extra stuff:
1 could be accomplished with a small go programs to wrap the logic for getting the binary either from disk ( 2 would need to be implemented on gokrazy level unless there is a Do you have any ideas how to work around the asset generation problem? |
Hi guys, I think a cool feature to add here (when the UI for the prometheus is working) is to add the Grafana stack. |
@BrunoTeixeira1996, to be clear. Prometheus is absolutely working. I just didn't find a "main stream" way to install it. Check out the first post in this thread. The best way would be to make prometheus (the upstream project) include the assets when building. I think if There is already a guide to Grafana you can find here: https://gokrazy.org/development/non-go/ |
Thanks for digging through the history.
Well, it can’t hurt to ask again. The discussions you linked to happened in 2015 and 2020, so maybe enough time has passed that they might reconsider. Regarding the problem of reproducibility: Whether the submitted assets will be used could be controlled by a build tag. There’s already the
The general approach I follow with such special cases is that the working copy is managed outside of gokrazy, to the point that when the gokrazy image is built, a For example, to include plugins in the Caddy webserver, the recommended approach is to underscore import the plugins and run the Caddy logic. So, instead of installing caddy directly in gokrazy, I instead have the following package main
import (
caddycmd "github.com/caddyserver/caddy/v2/cmd"
_ "github.com/caddyserver/caddy/v2/modules/standard"
_ "github.com/kirsch33/realip"
_ "github.com/caddyserver/transform-encoder"
)
func main() {
caddycmd.Main()
} In terms of updating this setup, I need to run We should probably add this more explicitly to https://gokrazy.org/userguide/automation/, but that page already lists a few recipes for how to accomplish things outside the scope of gokrazy (for example: configuration templating). So, in other words, I think custom installation, update or build steps, or otherwise massaging a piece of software into a consumable state for gokrazy, should be done before running the |
Done.
You could use upstream prometheus and map any assets via |
@stapelberg coming here from #287. Seems this issue is about including additional assets during build, with prometheus as example (update issue title to reflect this?). For https://github.com/evcc-io/evcc we have a similar issue, but with a twist. Our UI assets are included in the build (go:embed), but need be generated from the cloned repo before build (compile vue into js). We do this via Can we influence the build process or the build folder somehow? |
Updated the title.
To be clear, For example, in another project of mine, I’m using this setup:
If you can adopt this model of submitting the generated assets to git, you won’t need any extra steps.
My previous answer from July 2023 is still current: #208 (comment), specifically:
For the evcc case, I have already provided the exact recipe for such a setup over in #287:
Note the |
Thank you for your patience. It seems I'm missing two pieces of the puzzle: where does |
The
As explained in the quickstart section, The
If you’re ever in doubt where the file is located, you can run The builddir is located in the instance directory, i.e. next to
The |
And add options to the
config.json
forWaitForClock
,ExtraFilePaths
, andCommandLineFlags
for each of them to use a provided config file, e.g.--config.file=/etc/alertmanager/alertmanager.yml
.Unfortunately, prometheus server is the hard part, if you want the GUI to work. This requires the assets to be built first and I could not find a way to do this with the upstream module, only with a local copy.
Some notes:
-a
might not be necessary, but I did not check. It is what is used by thepromu
build tool.So this works for now, but I would prefer to not need to clone and update the prometheus repository manually.
If you have an idea how I could reliably get the assets for the build so I can use
gok add github.com/prometheus/prometheus/cmd/prometheus
, please let me know!Originally posted by @Syphdias in #51 (comment)
The text was updated successfully, but these errors were encountered: