<p>I refer <a href="https://cloud.google.com/community/tutorials/cloud-iot-prometheus-monitoring" rel="nofollow noreferrer">this doc</a>.</p>

<p>I want to send data from my device and visualize it on grafana so, how to connect prometheus(deployed as a cluster in gcp) to GCP pubsub.</p>

<p>Prometheus is <a href="https://prometheus.io/docs/introduction/faq/#why-do-you-pull-rather-than-push" rel="nofollow noreferrer">pull-based</a> rather than push-based. So, whatever the metrics source is, it must expose the metrics in Prometheus format, and Prometheus will periodically query them with HTTP request.</p>

<p>If directly exposing the metrics is not possible, the metrics source can push the metrics to some intermediate component which exposes the metrics in Prometheus format so that Prometheus can query them.</p>

<p>It seems this is the approach taken by the <a href="https://cloud.google.com/community/tutorials/cloud-iot-prometheus-monitoring" rel="nofollow noreferrer">document</a> you're referring to. The metrics are submitted from the source via PubSub to a Metrics Telemetry Converter pod running in the Kubernetes cluster, which exposes them in Prometheus format.</p>

<p>You then have to <a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/" rel="nofollow noreferrer">configure</a> Prometheus to scrape the metrics from this pod, as you would configure it for any other job.</p>
