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

rule error #3342

Closed
timchenxiaoyu opened this Issue Oct 24, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@timchenxiaoyu
Copy link

timchenxiaoyu commented Oct 24, 2017

caller=manager.go:485 component="rule manager" msg="loading groups failed" err="yaml: unmarshal errors:\n line 1: cannot unmarshal !!str ALERT c... into rulefmt.RuleGroups

kubectl get configmap prometheus-rules  -oyaml -n kube-system


apiVersion: v1
data:
  admin.rule: "ALERT container_cpu_usage_seconds_total_gt_1000_6f520219a26dc3a4cd66d439e9dced83\n\tIF
    (ceil(avg(rate(container_cpu_usage_seconds_total{id=\"/\",instance=\"test-slave-111\",job=\"kubernetes-nodes\",kubernetes_io_hostname=\"test-slave-111\"}[5m]))
    * 100 * 100) / 100) > 10\n\tLABELS {tenxClusterID=\"CID-ca4135da3326\", tenxNamespace=\"admin\",
    tenxStrategyID=\"STRAID-ggDYwFzTYWpS\", tenxStrategyName=\"ttt\", tenxTargetName=\"test-slave-111\",
    tenxTargetType=\"node\"}\n\tANNOTATIONS {condition=\"CPU利用率 > 10%\", createTime=\"2017-10-24T16:56:36+08:00\",
    currentValue=\"CPU利用率 {{ $value }}%\", tenxMetricType=\"cpu/usage_rate\", tokenMD5=\"9f834d0df08163e97b1ebb8423003292\"}\n"
kind: ConfigMap
metadata:
  creationTimestamp: 2017-10-24T08:56:22Z
  name: prometheus-rules
  namespace: kube-system
  resourceVersion: "54328149"
  selfLink: /api/v1/namespaces/kube-system/configmaps/prometheus-rules
  uid: 3547006c-b899-11e7-89e0-5254eec04736

prometheus version is 2.0

@gouthamve

This comment has been minimized.

Copy link
Member

gouthamve commented Oct 24, 2017

Hi, the rule format changed from 1.x. See: https://prometheus.io/blog/2017/06/21/prometheus-20-alpha3-new-rule-format/

You can use promtool to automatically convert the rules: promtool update rules <filenames>

@gouthamve gouthamve closed this Oct 24, 2017

@timchenxiaoyu

This comment has been minimized.

Copy link
Author

timchenxiaoyu commented Oct 24, 2017

promtool check rules /tmp/admin.rule
Checking /tmp/admin.rule
FAILED:
yaml: unmarshal errors:
line 1: cannot unmarshal !!str instanc... into rulefmt.RuleGroups

/bin $ cat /tmp/admin.rule
instance:network_bytes:rate1m = sum by(instance) (rate(network_bytes_total[1m]))

ALERT HighNetworkTraffic
IF instance:network_bytes:rate1m > 10e6

@timchenxiaoyu

This comment has been minimized.

Copy link
Author

timchenxiaoyu commented Nov 23, 2017

line 1: cannot unmarshal !!str ALERT c... into rulefmt.RuleGroups

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.