How can I export a counter metric with a value of zero?

Hello, everyone.

I am using a combination of promtail and prometheus to get a custom metric, and I am thinking of using the increment function to handle this.


My custom metric is of type counter, but as far as I know, counter values start at 1. Because of this, when the custom metric is output for the first time, the increment function does not return 1.

To work around this problem, I also tried or On() vector(0) but it did not give me the desired result because it treats the data series differently.
I think the only way to solve this problem is to output a metric with a value of 0 when there is no log output that matches the condition, but I don’t know how to do it.

Here is the sample config I am using and an example of the desired output.
I would also welcome any solutions other than what I have in mind.

- job_name: sample
  - targets:
      - localhost
      job: sample
      __path__: /var/log/sample.log
  - regex:
      expression: "^(?P<samplelog>hello,world\\.)$"
  - metrics:
        type: Counter
        description: "counter metric from promtail"
        source: samplelog
          action: inc
# HELP promtail_custom_metrics_from_promtail counter metric from promtail
# TYPE promtail_custom_metrics_from_promtail counter
promtail_custom_metrics_from_promtail{filename="/var/log/sample.log",job="sample"} 0