<p>Team,
I am new to prometheus. Please assist.</p>
<p>I have a k8s node and on that node locally i have a service running (lustre-exporter) which is exposing metrics as shown below.</p>
<pre><code>node:~$ curl http://localhost:9169/metrics | head -n 10
go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile=&quot;0&quot;} 8.4924e-05
go_gc_duration_seconds{quantile=&quot;0.25&quot;} 9.0081e-05
go_gc_duration_seconds{quantile=&quot;0.5&quot;} 9.2247e-05

</code></pre>
<p>I want to know how would i write a service monitor such that above is scraped by prometheus.</p>
<p>I tried below but getting syntax error from k8s.</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: lustre-exporter
  namespace: team-monitoring
spec:
  endpoints:
    - path: /metrics
      port: &quot;9169&quot;
</code></pre>
<pre><code>The ServiceMonitor &quot;lustre-exporter&quot; is invalid: []: Invalid value: map[string]interface {}{&quot;metadata&quot;:map[string]interface {}{&quot;name&quot;:&quot;lustre-exporter&quot;, &quot;namespace&quot;:&quot;team-monitoring&quot;, &quot;creationTimestamp&quot;:&quot;2022-07-01T02:14:16Z&quot;, &quot;generation&quot;:1, &quot;uid&quot;:&quot;824d31a3-f8e3-11ec-b65c-ac1f6b4ea082&quot;}, &quot;spec&quot;:map[string]interface {}{&quot;endpoints&quot;:[]interface {}{map[string]interface {}{&quot;path&quot;:&quot;/metrics&quot;, &quot;port&quot;:&quot;9169&quot;}}}, &quot;apiVersion&quot;:&quot;monitoring.coreos.com/v1&quot;, &quot;kind&quot;:&quot;ServiceMonitor&quot;}: validation failure list:
spec.selector in body is required
</code></pre>

AhmFM
<p>figured out and thanks for hint in comment but label selector was missing too.</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: lustre-exporter
  namespace: team-monitoring
spec:
  endpoints:
    - path: /metrics
      port: &quot;9169&quot;
  selector:
   nodeGroup: gpu
</code></pre>
