title: How to create grafana configmap for datasources?
body: <p>I am trying to create a configmap for a Grafana datasource, using an instance of Grafana from the Kube-Prometheus-Stack helm chart <a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack" rel="noreferrer">https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack</a></p>
  <p>I am aware for dashboards, you can create a configmap from a json file using the commands listed in this answer: <a href="https://stackoverflow.com/questions/57322022/stable-prometheus-operator-adding-persistent-grafana-dashboards">stable/prometheus-operator - adding persistent grafana dashboards</a></p>
  <pre><code>wget https://raw.githubusercontent.com/percona/grafana-dashboards/master/dashboards/MongoDB_Overview.json
  kubectl -n monitoring create cm grafana-mongodb-overview --from-file=MongoDB_Overview.json
  kubectl -n monitoring label cm grafana-mongodb-overview grafana_dashboard=mongodb-overview
  </code></pre>
  <p>Can something similar be done for grafana datasources? I currently have a datasource.yaml which contains the following lines:</p>
  <pre class="lang-yaml prettyprint-override"><code>    data:
        datasource-PRF1-Prometheus.yaml: |-
          apiVersion: 1
          datasources:
            - name: Test-Prometheus
              type: prometheus
              url: https://prometheus.url.net/
              access: Server
              isDefault: true
              basicAuth: true
              basicAuthPassword: password
              basicAuthUser: admin
  </code></pre>
  <p>However, I am not able to import a datasource using it, even though it creates a configmap.</p>