<p>I have installed loki and grafana via helm charts to my cloud hosted k8s cluster. How do I send the loki metrics to grafana cloud? I know I should edit the promtail config file but how do I locate and view/edit helm chart files?</p>
<p>My installation procedure for loki+grafana are:</p>
<pre><code>helm upgrade --install loki --namespace=monitoring grafana/loki-stack
helm upgrade --install grafana --namespace=monitoring grafana/grafana
kubectl port-forward service/grafana 3000:80 -n monitoring
</code></pre>
<p>This installation of loki only exposes loki to grafana locally. I wish to enter the configuration of loki (or more specifically promtail) so that I can send the loki logs to my grafana cloud account and monitor the logs from grafana cloud as well.
I have done this in a non-k8s setting by modifying the promtail-config.yaml which is referenced to send the logs to grafana cloud. Adding the grafana cloud url to the promtail config such as:</p>
<pre><code>clients:
  - url: http://loki:3100/loki/api/v1/push
  - url: https://123456:ekw0...=@logs-prod3.grafana.net/api/prom/push
</code></pre>
<p>When I explore grafana cloud &gt; intergrations and connections &gt; loki hosted logs &gt; k8s cluster. I receive the following instructions</p>
<blockquote>
<p>Your configuration, complete with your
API key, has been generated below. Copy and paste this code to
promtail/config.yaml to send data using promtail.</p>
</blockquote>
<p>The code snippet:</p>
<pre><code>curl -fsS https://raw.githubusercontent.com/grafana/loki/master/tools/promtail.sh | sh -s 123456 eB9... logs-prod3.grafana.net default | kubectl apply --namespace=default -f  -
</code></pre>
<p>I am new to helm charts, so I do not know how to view the helm config files and where they are stored. Or how to obtain the <code>promtail/config.yaml</code> file from helm or the k8s cluster.</p>

<p>I'm not an expert in Loki but I downloaded the default values.yaml that Chart uses and there seems an option to mention the Promtail configuration which should help you (shown below) and looking at the commands above, it seems Helm would have used default values to install the chart, you can still modify them in 2 ways.</p>
<p>1st: Run the below to get the values.yaml that was used to install the chart by default, modify the Promtail configuration and then upgrade the installation using the modified values.yaml</p>
<pre><code>helm get values -n monitoring grafana/loki-stack loki &gt; values.installed.loki.yaml

*Modify the values.installed.loki.yaml, on line number 5 there are a few *promtail configuration you may need to set
 promtail:
   enabled: true
   config:
     lokiAddress: http://{{ .Release.Name }}:3100/loki/api/v1/push


Once done, upgrade the chart with the modified values with -f flag
helm upgrade --install loki --namespace=monitoring grafana/loki-stack -f values.installed.loki.yaml
</code></pre>
<p>2nd: Get the default values.yaml as shown below which is used for Loki installation, modify the promtail configuration and upgrade the installation as shown below</p>
<pre><code>helm show values grafana/loki-stack &gt; values.loki.yaml

Modify values.loki.yaml for the promtail configuration and upgrade the chart
 promtail:
   enabled: true
   config:
     lokiAddress: http://{{ .Release.Name }}:3100/loki/api/v1/push

Run an upgrade on the existing installation with the new values.yaml

helm upgrade --install loki --namespace=monitoring grafana/loki-stack -f values.loki.yaml
</code></pre>
