<p>I am writing an exporter and am having trouble with metrics for my collector. From what I can tell, metrics in Prometheus need to be defined beforehand. Is there any way to define them dynamically at runtime instead? I won't know how many metrics I'll have or what metrics I'll need until the code is running. (For example, if k8s finds all volumes connected to the cluster, and I need EACH volume to get its own total_capacity/available_capacity metric).</p>

<p>You would handle this by using dynamic label values rather than dynamic metric names. That said, you can call <code>prometheus.Register()</code> at runtime just fine, client_golang won't know the difference.</p>
