Skip to content
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

How to bootstrap prepared queries #1956

Open
johntdyer opened this issue Apr 17, 2016 · 6 comments
Open

How to bootstrap prepared queries #1956

johntdyer opened this issue Apr 17, 2016 · 6 comments
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature
Milestone

Comments

@johntdyer
Copy link

I would like to bootstrap a cluster to "start" with some prepared queries but the docs only show adding them via the rest API. Is there a way to pre-seed them ? Is there also a way to back them up ?

@johntdyer
Copy link
Author

Any chance anyone has an idea on this ?

@slackpad
Copy link
Contributor

Hi @johntdyer similar to K/V, prepared queries belong to the cluster and not any individual agent, so they cannot be configured as part of an agent's config file. If you wanted to pre-seed them you'd need to script that outside of Consul with something like curl or using one of the Consul API clients. We have future plans for a better backup system on #1254, which would include prepared queries. Most existing backup solutions only persist K/V, so at present the best way to back up your query definitions would be to save off a GET to /v1/query using a management token which will enumerate all defined queries in one request.

@johntdyer
Copy link
Author

Are queries idempotent ? Could I run a check looking for a missing query and then readd it incase it somehow ended up "mIssing"?

@slackpad
Copy link
Contributor

You could run a check and add a missing query, but it's a little tricky because you can't control the ID when you create a query. I'm assuming you are giving your queries a Name in which case the first attempt to create a query with that name will go through and subsequent ones will fail.

Not sure if you are creating queries for a bunch of different services, but perhaps prepared query templates might help you here by defining a single query with a pattern that applies to multiple services; this is new for 0.6.4.

@slackpad
Copy link
Contributor

slackpad commented May 2, 2017

See #717 (comment) for a possible implementation idea for this.

@slackpad slackpad added type/enhancement Proposed improvement or new feature post-0.9 labels May 2, 2017
@slackpad slackpad added the theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner label May 25, 2017
@slackpad slackpad added this to the Unplanned milestone Jan 5, 2018
@slackpad slackpad removed the post-0.9 label Jan 5, 2018
@pearkes
Copy link
Contributor

pearkes commented Nov 28, 2018

Just wanted to drop a note for future readers that the Consul Terraform Provider supports a prepared_query resource that can potentially provide a nice workflow to bootstrap and manage prepared queries, but isn't a direct solution for this ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature
Projects
None yet
Development

No branches or pull requests

3 participants