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

max_idle_duration could not be parsed as a time.Duration: 'time: unknown unit d in duration 1d #3125

Closed
kenwoodjw opened this issue Jan 6, 2021 · 1 comment

Comments

@kenwoodjw
Copy link

kenwoodjw commented Jan 6, 2021

Describe the bug
image

Version

  1. loki version 1.6.1
  2. promtail version 1.6.1

Expected behavior

cat /etc/promtail/promtail.yml
 pipeline_stages:
  - match:
      selector: '{app="geoserver"} |~ ".*(error|ERROR|panic|PANIC|Exception).*"'
      stages:
      - regex: {expression: '.*(?P<error>(error|ERROR|Exception)).*'}
      - regex: {expression: '.*(?P<panic>(panic|PANIC)).*'}
      - metrics:
          error_total:
            config: {action: inc}
            description: total count of error
            max_idle_duration: 1d  
            source: error
            type: Counter

systemctl restart promtail
 promtail.service - Promtail service
   Loaded: loaded (/etc/systemd/system/promtail.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2021-01-06 10:21:27 CST; 1s ago
  Process: 868644 ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/promtail.yml (code=exited, status=1/FAILURE)
 Main PID: 868644 (code=exited, status=1/FAILURE)

1月 06 10:21:26 localhost systemd[1]: Started Promtail service.
1月 06 10:21:27 localhost promtail[868644]: level=error ts=2021-01-06T02:21:27.084879466Z caller=main.go:106 msg="error creating promtail" error="failed to make file target manager: invalid match stage config: match stage failed to create pipeline from config: map[selector:{app=\"geoserver\"} |~ \".*(error|ERROR|panic|PANIC|Exception).*\" stages:[map[regex:map[expression:.*(?P<error>(error|ERROR|Exception)).*]] map[regex:map[expression:.*(?P<panic>(panic|PANIC)).*]] map[metrics:map[error_total:map[config:map[action:inc] description:total count of error max_idle_duration:1d source:error type:Counter]]] map[metrics:map[panic_total:map[config:map[action:inc] description:total count of panic max_idle_duration:1d source:panic type:Counter]]]]]: invalid metrics stage config: max_idle_duration could not be parsed as a time.Duration: 'time: unknown unit \"d\" in duration \"1d\"'"
1月 06 10:21:27 localhost systemd[1]: promtail.service: main process exited, code=exited, status=1/FAILURE
1月 06 10:21:27 localhost systemd[1]: Unit promtail.service entered failed state.
1月 06 10:21:27 localhost systemd[1]: promtail.service failed.


Source code:
https://github.com/grafana/loki/blob/c4faa579e33b33afa2c15bca72796d000e6b79fb/pkg/logentry/stages/metrics.go#L67```
use ParseDuration function
https://golang.org/pkg/time/#ParseDuration

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

Question
Why document use 1d
#2335

@owen-d
Copy link
Member

owen-d commented Jan 8, 2021

Good catch, this shouldn't use an unregistered unit.
fixed in #3124

@owen-d owen-d closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants