<p>I have an application running on kubernetes (It is a cluster running on cloud) and want to setup monitoring and logging for that application. There are various possibilities for the setup. What would be the best practices of doing that, like recommended method or industrial standard?</p>
<ul>
<li>A <strong>prometheus monitoring setup inside kubernetes cluster</strong>: prometheus-operator helm chart installed inside the cluster that can monitor the entire cluster, including the application.</li>
<li>an <strong>external prometheus + grafana setup</strong> deployed with docker-compose.(But I doubt if the external setup can reach the k8s properly to scrape all the metrics)</li>
<li>A <strong>prometheus federation setup</strong> where one external prometheus setup gets metrics from an internal prometheus setup of k8s.</li>
</ul>
<p>Can anyone please help me with some suggestions regarding best practices?</p>

<p>It all depends on how many clusters you have. If you have one cluster, the application you want to monitor on it will be the best choice option 1:</p>
<blockquote>
<ul>
<li>A  <strong>prometheus monitoring setup inside kubernetes cluster</strong>  : prometheus-operator helm chart installed inside the cluster that can monitor the entire cluster, including the application.</li>
</ul>
</blockquote>
<p>The advantages of such a solution include possibly simple and quick configuration, in addition, you have everything in one place (application and Prometheus) and you do not need a new cluster to monitor another. <a href="https://www.replex.io/blog/kubernetes-in-production-the-ultimate-guide-to-monitoring-resource-metrics-with-grafana" rel="nofollow noreferrer">Here</a> you can find example tutorial.</p>
<p>However, if you plan to expand to many clusters, or you already need to monitor many clusters, option 3 will be the best choice:</p>
<blockquote>
<ul>
<li>A  <strong>prometheus federation setup</strong>  where one external prometheus setup gets metrics from an internal prometheus setup of k8s.</li>
</ul>
</blockquote>
<p>Thanks to this solution, you will have all the metrics in one place, regardless of the <a href="https://prometheus.io/docs/prometheus/latest/federation/" rel="nofollow noreferrer">number of clusters</a> you need to monitor:</p>
<blockquote>
<p>Commonly, it is used to either achieve scalable Prometheus monitoring setups or to pull related metrics from one service's Prometheus into another.</p>
</blockquote>
<p>You can find example tutorials about <a href="https://medium.com/@jotak/prometheus-federation-in-kubernetes-4ce46bda834e" rel="nofollow noreferrer">Prometheus federation in Kubernetes</a> and <a href="https://banzaicloud.com/blog/prometheus-federation/" rel="nofollow noreferrer">Monitoring multiple federated clusters with Prometheus - the secure way</a></p>
