StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
5.96k stars 744 forks source link

Feature: Add "st2 rule search", "st2 action search" to CLI #2973

Open codyaray opened 7 years ago

codyaray commented 7 years ago

I quite regularly (almost daily) have to pop into MongoDB to search for specific rules or actions. This is because we have far too many of each to do "st2 rule list | grep", they're all in one pack, and they have a predictable naming scheme. To detail our use case a bit more, we have a cron pack where we keep a ton of rules with many named like <app>_<start|stop>_<hostname>. The existing list filters for pack, action, and trigger aren't super helpful in this scenario. So I tend to use mongo to search for hostname, or for the app name, or for app_start, etc., for a particular rule, action, or (occasionally) action execution.

db.rule_d_b.find({"uid":/.*some-search-string.*/},{"uid":1,"_id":0}).count()

I'm going to write a little helper script so others on my team have this functionality at-hand, but thought a feature request might make it part of core and helper others too.

pixelrebel commented 7 years ago

We also need st2 key search Would be great to pull up kvs by prefix.

codyaray commented 7 years ago

I wrote a helper script to search in the meantime. I've updated it to support st2search.py key <pattern> for you @pixelrebel. https://gist.github.com/codyaray/d782c370de3fa2a4c7f0e27f67b3c395

lakshmi-kannan commented 7 years ago

@pixelrebel st2 key list --prefix= should work today.

pixelrebel commented 7 years ago

@lakshmi-kannan That's great! I didn't realize there's help pages for the sub commands! But st2 key list -h reflects this feature. Thanks!

estee-tew commented 7 years ago

https://stackstorm.slack.com/archives/community/p1492018976099518