Grafana throws HTTP Error Bad Gateway for Prometheus data source - kubernetes

I have Grafana and Prometheus set up on my k8s cluster. Both were installed thru helm using https://github.com/helm/charts/tree/master/stable.
Both Grafana and Prometheus are set up thru k8s nginx ingress with my domian addresses.
When I try to set up the Prometheus as a data source in Grafana I get HTTP Error Bad Gateway. In the chrome console in Grafana page I see:
http://grafana.domain.com/api/datasources/proxy/1/api/v1/query?query=1%2B1&time=1554043210.447
Grafana version: Grafana v6.0.0 (commit: 34a9a62)
Grafana data source settings for Prometheus:
URL: https://prometheus.mydomain.com:9090
Access: Server(Default)
Auth:
Basic & TLS Client Auth
What might be wrong and how to debug/fix it?

In Grafana data source settings for prometheus database add prometheus service dns and service port. Like below
<prometheus service name>. Namespace. Svc. Cluster. Local:9090

if you are run Grafana and Prometheus on docker on your local machine and this will do for the datasource settings
Add host as {host.docker.internal} : {port}
example - http://{host.docker.internal}:9090

When you are trying to add a data source, like Prometheus it is a little bit confusing because they are asking for the http, but you have to put your IP adress.
You just have to open CMD and write ipconfig /all and then look at the IPv4 Direction and then you will have your IP.
So the last part is going to Prometheus and in the URL you have to put:
http://{your_IP}:9090

Related

Forward internal request to internal DNS with CoreDNS w/ Kubernetes

I'd like to connect to my nextcloud instance using the internal DNS server (CoreDNS) provided by Kubernetes. I am on remotely connected to the cluster through an Wireguard VPN deployed in Kubernetes:
It clearly states that I am using the CoreDNS server 10.43.0.10 used by all other services:
My nextcloud instance is using the traefik ingress controller described in this file:
Putting
10.43.223.221 nextcloud.local
in my /etc/hosts allows me to access the instance but when if I add a line in my Corefile (as seen in the photo below) to route the nextcloud.local to 10.43.223.221 nothing happens.
What should I do to make it work. I want every peer that is connected to that wireguard instance to be able to use those DNS queries.
Thanks!
I managed to solve my problem by following the solution described in CoreDNS do not respect local DNS. I just added this into my corefile:

HTTP codes monitoring for Kubernetes cluster using MetalLB ingress controller

Having a cluster running on VMs on our private cloud and using MetalLB as ingress-controller we need to see the network traffic and HTTP codes returned from our applications to see in Grafana HTTP requests and traffic load the way you see it on AWS Load Balancers for example.
We have deployed Prometheus through the Helm deployment in all nodes so we can gather metrics from all the cluster but didn't find any metric containing the needed information. Tried looking the metrics in Prometheus about ingresses, proxy, http but there is nothing matching our need. Also tried some Grafana dashboards from the repository but nothing shows the metrics.
Thanks.

Connect gitlab to kubernetes cluster hosted in rancher

I am trying to connect to a rancher2 kubernetes cluster from gitlab. My kube config looks like
apiVersion: v1
kind: Config
clusters:
- name: "k8s"
cluster:
server: "https://..."
- name: "k8s-desktop"
cluster:
server: "https://192.168.0.2:6443"
certificate-authority-data: ...
I need to point gitlab to the name.cluster.server value being https://192.168.0.2:6443, this is an internal IP. How can I override this value in kube config using my external IP so gitlab is able to connect?
When you log into Rancher, you can get the kubeconfig file. This will use the Rancher url on port 443. Your kubeconfig seems to be pointing directly to your k8s node, as the kubeconfig you obtain when using RKE.
If by external ip, you mean connect from outside, then you need a device capable of port forwarding. Please clarify what you mean by internal / external ip.
From my side, i have no problem to give gitlab the Rancher url in order to connect to k8s. Rancher will proxy the connection to the k8s cluster.
I dont see any reasons to change you server ip to External.
What you should do is create port forwarding from internal https://192.168.0.2:6443 to your external ip. And then use External url with port forwarded port in Gitlab Kubernetes API URL.

Kubernetes: The proxy server is refusing connections

I have started with kubernetes and followed this link to get the response as they mentioned. I followed the exact steps but when I am trying to open the port I get the following error:
How to solve this issue? I have tried by adding the IP address and port in the Browser proxy.
Can anyone help me on this?
Here is the service image: my service image
List of pods: Kubectl Pods
List of kubectl deployments:Deployment List
I believe you're using the baremetal(simple laptop) to deploy your service.
If you have look at my-service it is in pending state and it is of type LoadBalancer. The type load balance is supported only for the cloud providers like aws,azure and google cloud. Hence you are not able to access anything.
I will suggest you to follow this tutorial here which allow you to deploy nginx as a pod and deploy a service around that and export that service as nodeport (without load balancer) to be able to access from outside.

unable to get the system service memory and cpu metrics of kubernetes cluster in grafana dashboard using prometheus

I am trying to monitor my kubernetes cluster metrics using Prometheus and grafana. Here is the link which was i followed. Facing the issue with kubernetes-service-endpoints (2/3 up) in my Prometheus dashboard.
below is grafana dashboard which is used in this task.
I checked my Prometheus pod logs .It shows the errors like
Could anybody suggest how to get system services metrics in the above dashboard?
(or)
suggest me the any grafana dashboard name for monitoring the kubernetes cluster using Prometheus?
Check your prometheus.yaml it should have static configs as for prometheus,
static_configs:
- targets:
- localhost:9090
curl localhost:9090/metrics and make sure you're receiving metrics as output
For grafana dashboard, create an org -> prometheus as data source configure prometheus IP:PORT and click on test and confirm connectivity is available.
Open .json file and change the configs according your requirements and import and check.