You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page shows you how to send application logs created in a Kubernetes cluster to your Cockpit either by using a Helm chart or by deploying a Helm chart with [Terraform](https://www.terraform.io/).
16
+
In this page we will show you how to send application logs from your Kubernetes cluster to your Cockpit using either a Helm chart or deploying a Helm chart with [Terraform](https://www.terraform.io/).
17
17
18
-
In this example, we use [k8s-monitoring](https://artifacthub.io/packages/helm/grafana/k8s-monitoring/1.6.16) which installs an Alloy Daemon set to your Kubernetes cluster to export logs to your Cockpit.
18
+
We will use the [k8s-monitoring](https://artifacthub.io/packages/helm/grafana/k8s-monitoring/1.6.16)Helm Chart, which installs an Alloy Daemon set to export your Kubernetes cluster's logs to your Cockpit.
19
19
20
20
<Macroid="requirements" />
21
21
22
22
- A Scaleway account logged into the [console](https://console.scaleway.com)
23
23
-[Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization
24
-
-[Created](/observability/cockpit/how-to/create-external-data-sources/) a custom external data source
24
+
-[Created](/observability/cockpit/how-to/create-external-data-sources/) a custom external data source of the [logs type](/observability/cockpit/concepts/#data-types)
25
25
-[Created](/observability/cockpit/how-to/create-token/) a Cockpit token for the same region as the data source
26
26
- A running Kubernetes cluster containing your application deployed
27
27
-[Created](/identity-and-access-management/iam/how-to/create-api-keys/) an API key and retrieved your API secret key
@@ -32,7 +32,7 @@ In this example, we use [k8s-monitoring](https://artifacthub.io/packages/helm/gr
32
32
33
33
## Configure the Helm chart
34
34
35
-
Create a `values.yml` file to configure your Helm chart, using the example below. Make sure that you replace `$SCW_CLUSTER_NAME` with the name of your Scaleway Kubernetes cluster, `$COCKPIT_CUSTOM_DATASOURCE_HOST` with the hostname of your custom endpoint, and `$COCKPIT_TOKEN` with your Cockpit token.
35
+
Create a `values.yml` file to configure your Helm chart, using the example below. Make sure that you replace `$SCW_CLUSTER_NAME` with the name of your Scaleway Kubernetes cluster, `$COCKPIT_CUSTOM_DATASOURCE_HOST` with the URL of your custom data source (you can find it under the "API URL" section in the [Data sources tab](https://console.scaleway.com/cockpit/dataSource) of the Scaleway console), and `$COCKPIT_TOKEN` with your Cockpit token.
url: "$COCKPIT_CUSTOM_LOGS_DATASOURCE_URL/loki/api/v1/push"##You can find your logs URL in the **Data sources** tab of the Scaleway conseole under the "API URL" section of the relevant data source
49
49
tenantId: "$COCKPIT_TOKEN"
50
50
51
51
metrics:
@@ -77,37 +77,51 @@ alloy-singleton:
77
77
```
78
78
79
79
<Message type="info">
80
-
The template above is only an example to send logs to your Cockpit. You can also send metrics to Cockpit using this Helm chart.
81
-
You can check our guide to [send metrics from your cluster to Cockpit](// ADD LINK TO METRICS TUTO)
80
+
The template above is for sending logs to your Cockpit. You can also configure it to send metrics to Cockpit using this Helm chart.
81
+
Refer to our dedicated doucumentation to [send metrics from your cluster to Cockpit](/observability/cockpit/how-to/send-metrics-froms-k8s-to-cockpit).
82
82
</Message>
83
83
84
-
## Send Kubernetes logs to your Cockpit using Helm chart
84
+
## Send Kubernetes logs using Helm chart
85
85
86
-
1. Connect your kubectl to your Kubernetes cluster
87
-
2. Run the following command to apply your Helm chart with the `values.yml` file:
86
+
Once you have configured your `values.yml` file, you can use Helm to deploy the log-forwarding configuration to your Kubernetes cluster. Before you can install the Helm chart, ensure that your `kubectl` tool is properly connected to your Kubernetes cluster. `kubectl` is the command-line tool for interacting with Kubernetes clusters.
87
+
88
+
1. [Connect](/containers/kubernetes/how-to/connect-cluster-kubectl/) `kubectl` to your Kubernetes cluster
89
+
2. Run the command below to install the `k8s-monitoring` Helm chart:
Make sure to replace `-f` flag with the correct path to your `values.yml` file.
93
+
The `-f` flag specifies the path to your `values.yml` file, which contains the configuration for the Helm chart. Make sure that you replace `/your-path/to/values.yml` with the correct path where your `values.yml` file is stored. Make sure that you also replace `your-log-ingester` with the log ingester of your choice. In our configuration we are using `alloy-lm-ingester`.
94
+
95
+
Helm installs the `k8s-monitoring` chart, which includes the Alloy DaemonSet configured to collect logs from your Kubernetes cluster.
96
+
The DaemonSet ensures that a pod is running on each node in your cluster, which collects logs and forwards them to the specified Loki endpoint in your Cockpit.
97
+
98
+
3. Optionally, check the status of the release to ensure it was installed:
92
99
93
-
## Send Kubernetes logs to your Cockpit using Helm chart with Terraform
100
+
```
101
+
helm list
102
+
```
103
+
You should see a list of all the Helm releases in your cluster, including `my-log-ingester`.
94
104
95
-
1. Set up the Helm Terraform provider:
105
+
## Send Kubernetes logs using Helm chart with Terraform
106
+
107
+
You can also use Terraform to manage and deploy Helm charts, providing you with more automation and consistency to manage your Kubernetes resources.
108
+
109
+
1. Create a `provider.tf` file and paste the following template to set up the Helm Terraform provider:
96
110
```terraform
97
111
provider "helm" {
98
112
kubernetes {
99
-
host = your_k8s_cluster_host
100
-
token = your_k8s_cluster_token
113
+
host = your_k8s_cluster_host # The URL of your Kubernetes API server.
114
+
token = your_k8s_cluster_token # Authentication token to access the cluster.
101
115
cluster_ca_certificate = base64decode(
102
-
your_k8s_cluster_ca_certificate
116
+
your_k8s_cluster_ca_certificate # The cluster's CA certificate, base64 encoded.
103
117
)
104
118
}
105
119
}
106
120
```
107
-
2. Create a Helm release resourcewith the path to your `values.yml`:
121
+
2. Create a `maint.tf` file and paste the following template to create a Helm release resource. Make sure that you replace `/your-path/to/values.yml` with the actual path to your values file.
@@ -117,13 +131,20 @@ You can check our guide to [send metrics from your cluster to Cockpit](// ADD LI
117
131
values= [file("/your-path/to/values.yml")]
118
132
}
119
133
```
120
-
3. Run `terraform apply` to apply the new Terraform configuration.
134
+
3. Save your changes.
135
+
4. Run `terraform init` to initialize your Terraform configuration and download any necessary providers.
136
+
5. Run `terraform apply` to apply your configuration.
137
+
5. Type `yes` when prompted to confirm the actions.
121
138
122
139
## Explore your logs in Cockpit
123
140
124
-
Now that your logs are exported to your Cockpit, you can access and query them.
125
-
126
-
1. Click **Cockpit** in the Observability section of the [console](https://console.scaleway.com/) side menu. The **Cockpit** overview page displays.
141
+
1. Click **Cockpit** in the Observability section of the Scaleway [console](https://console.scaleway.com/) side menu. The **Cockpit** overview page displays.
127
142
2. Click **Open dashboards** to open your managed dashboards in Grafana. You are redirected to the Grafana website.
128
-
3. Click the **Home** icon > **Explore**. Select your custom data source in the upper left corner.
129
-
4. Filter the query by only searching for the label `cluster` with the value corresponding to your cluster name and your logs should display.
143
+
3. Log in to Grafana using your [Grafana credentials](/observability/cockpit/how-to/retrieve-grafana-credentials/).
144
+
4. Click the **Home** icon, then click **Explore**.
145
+
5. Select your custom data source in the search drop-down on the upper left corner of your screen.
146
+
6. In the **Labels filter** drop-down, select the `cluster` label and in the **Value** drop-down, select your cluster.
147
+
7. Optionally, click the **Clock** icon on the top right corner of your screen and filter by time range.
148
+
8. Click **Run query** to see your logs. An output similar to the following should display.
0 commit comments