Skip to content

Commit

Permalink
规则和模板提示统一
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Jul 15, 2020
1 parent 60dd6b7 commit f43e46e
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 162 deletions.
12 changes: 5 additions & 7 deletions dashboard/src/components/MatchRuleHelp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
</li>
<li>支持的函数:
<ul>
<li><code>JsonGet(key string, defaultValue string) string</code> 将消息体作为json解析,获取指定的key</li>
<li><code>Upper(val string) string</code> 字符串转大写</li>
<li><code>Lower(val string) string</code> 字符串转小写</li>
<li><code>Now() time.Time</code> 当前时间</li>
<li><code>ParseTime(layout string, value string) time.Time</code> 时间字符串转时间对象</li>
<li><code>DailyTimeBetween(startTime, endTime string) bool</code> 判断当前时间是否在 startTime 和 endTime 之间(每天),时间格式为 15:04</li>
<li v-for="(helper, i) in helpers" v-bind:key="i"><code>{{ helper.text }}</code> {{ helper.displayText }}</li>
</ul>
</li>
</b-card-body>
</template>

<script>
export default {
name: "MatchRuleHelp"
name: "MatchRuleHelp",
props: {
helpers: Array,
}
}
</script>

Expand Down
32 changes: 5 additions & 27 deletions dashboard/src/components/TemplateHelp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,7 @@ Group: {
</li>
<li>支持的函数:
<ul>
<li><code>cut_off(maxLen int, val string) string</code> 字符串截断</li>
<li><code>implode(elems []string, sep string) string</code> 字符串数组拼接</li>
<li><code>explode(s, sep string) []string</code> 字符串分隔成数组</li>
<li><code>ident(ident string, message string) string</code> 多行字符串统一缩进</li>
<li><code>json(content string) string</code> JSON 字符串格式化</li>
<li><code>datetime(datetime time.Time) string</code> 时间格式化展示为 2006-01-02 15:04:05 格式,时区选择北京/重庆</li>
<li><code>datetime_noloc(datetime time.Time) string</code> 时间格式化展示为 2006-01-02 15:04:05 格式,默认时区</li>
<li><code>json_get(key string, defaultValue string, body string) string</code> 将 body 解析为 json,然后获取 key 的值,失败返回 defaultValue</li>
<li><code>json_gets(key string, defaultValue string, body string) string</code> 将 body 解析为 json,然后获取 key 的值(可以使用逗号分割多个key作为备选),失败返回 defaultValue</li>
<li><code>json_array(key string, body string) []string</code> 将 body 解析为 json,然后获取 key 的值(数组值)</li>
<li><code>json_flatten(body string, maxLevel int) []jsonutils.KvPair</code> 将 body 解析为 json,然后转换为键值对返回</li>
<li><code>starts_with(haystack string, needles ...string) bool</code> 判断 haystack 是否以 needles 开头</li>
<li><code>ends_with(haystack string, needles ...string) bool</code> 判断 haystack 是否以 needles 结尾</li>
<li><code>trim(s string, cutset string) string</code> 去掉字符串 s 两边的 cutset 字符</li>
<li><code>trim_left(s string, cutset string) string</code> 去掉字符串 s 左侧的 cutset 字符</li>
<li><code>trim_right(s string, cutset string) string</code> 去掉字符串 s 右侧的 cutset 字符</li>
<li><code>trim_space(s string) string</code> 去掉字符串 s 两边的空格</li>
<li><code>format(format string, a ...interface{}) string</code> 格式化展示,调用 fmt.Sprintf </li>
<li><code>integer(str string) int</code> 字符串转整数 </li>
<li><code>mysql_slowlog(slowlog string) map[string]string</code> 解析 MySQL 慢查询日志为 map </li>
<li><code>open_falcon_im(msg string) OpenFalconIM</code> 解析 OpenFalcon 消息格式 </li>
<li><code>string_mask(content string, left int) string</code> 在左右两侧只保留 left 个字符,中间所有字符替换为 * </li>
<li><code>string_tags(tags string, sep string) []string</code> 将字符串 tags 用 sep 作为分隔符,切割成多个 tag,空的 tag 会被排除 </li>
<li><code>remove_empty_line(content string) string</code> 移除字符串中的空行</li>
<li><code>meta_filter(meta map[string]interface{}, allowKeys ...string) map[string]interface{}</code> 过滤Meta,只保留允许的Key</li>
<li><code>meta_prefix_filter(meta map[string]interface{}, allowPrefix ...string) map[string]interface{}</code> 过滤Meta,只保留包含指定 prefix 的Key</li>
<li v-for="(helper, i) in helpers" v-bind:key="i"><code>{{ helper.text }}</code> {{ helper.displayText }}</li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -118,7 +93,10 @@ type KvPair struct {

<script>
export default {
name: "TemplateHelp"
name: "TemplateHelp",
props: {
helpers: Array,
}
}
</script>

Expand Down
18 changes: 5 additions & 13 deletions dashboard/src/components/TriggerHelp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,7 @@ Trigger {
</li>
<li>支持的函数:
<ul>
<li><code>Upper(val string) string</code> 字符串转大写</li>
<li><code>Lower(val string) string</code> 字符串转小写</li>
<li><code>Now() time.Time</code> 当前时间</li>
<li><code>ParseTime(layout string, value string) time.Time</code> 时间字符串转时间对象</li>
<li><code>DailyTimeBetween(startTime, endTime string) bool</code> 判断当前时间是否在 startTime 和 endTime 之间(每天),时间格式为 15:04</li>
<li><code>Messages() []repository.Message</code> 获取分组中所有的 Messages</li>
<li><code>MessagesCount() int64</code> 获取分组中 Messages 数量</li>
<li><code>MessagesMatchRegexCount(regex string) int64</code> 获取匹配指定正则表达式的 message 数量</li>
<li><code>MessagesWithMetaCount(key, value string) int64</code> 获取 meta 匹配指定 key=value 的 message 数量</li>
<li><code>MessagesWithTagsCount(tags string) int64</code> 获取拥有指定 tag 的 message 数量,多个 tag 使用英文逗号分隔</li>
<li><code>TriggeredTimesInPeriod(periodInMinutes int, triggerStatus string) int64</code> 当前规则在指定时间范围内,状态为 triggerStatus 的触发次数</li>
<li><code>LastTriggeredGroup(triggerStatus string) repository.MessageGroup</code> 最后一次触发该规则的状态为 triggerStatus 的分组</li>
<li v-for="(helper, i) in helpers" v-bind:key="i"><code>{{ helper.text }}</code> {{ helper.displayText }}</li>
</ul>
</li>
</ul>
Expand All @@ -65,7 +54,10 @@ Trigger {

<script>
export default {
name: "TriggerHelp"
name: "TriggerHelp",
props: {
helpers: Array,
}
}
</script>

Expand Down
Loading

0 comments on commit f43e46e

Please sign in to comment.