Skip to content

Commit 5bfeb6e

Browse files
grafana doc added
1 parent ed6e724 commit 5bfeb6e

File tree

4 files changed

+235
-2
lines changed

4 files changed

+235
-2
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
### 1. Install Required Nuget Package
2+
---
3+
4+
```
5+
- AWS.MSK.Auth
6+
- Streamiz.Kafka.Net.SchemaRegistry.SerDes.Avro
7+
```
8+
9+
### 2. Setup OAuthCallBack Function
10+
---
11+
12+
```cs
13+
var mskAuthTokenGenerator = new AWSMSKAuthTokenGenerator();
14+
15+
private void OauthCallback(IClient client, string cfg)
16+
{
17+
try
18+
{
19+
var (token, expiryMs) = mskAuthTokenGenerator.GenerateAuthToken(Amazon.RegionEndpoint.APSouth1); //Change The RegionEndpoint for Your MSK Region.
20+
client.OAuthBearerSetToken(token, expiryMs, "DummyPrincipal");
21+
}
22+
catch (Exception e)
23+
{
24+
client.OAuthBearerSetTokenFailure(e.ToString());
25+
}
26+
}
27+
```
28+
29+
### 3. ConsumerConfig Setup
30+
---
31+
32+
```cs
33+
var config = new ConsumerConfig()
34+
{
35+
BootstrapServers = "<HOST>:<PORT>",
36+
GroupId = "Kafka-Consumer",
37+
AutoOffsetReset = AutoOffsetReset.Latest,
38+
SecurityProtocol = SecurityProtocol.SaslSsl,
39+
SaslMechanism = SaslMechanism.OAuthBearer
40+
};
41+
```
42+
43+
### 4. Setup ConsumerBuild
44+
---
45+
#### With ScheamRegistry
46+
47+
```cs
48+
var schemaRegistryConfig = new SchemaRegistryConfig
49+
{
50+
Url = "http://<scheamRegistryHost>:<Port>";
51+
};
52+
53+
var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig);
54+
55+
service.AddSingleton<IConsumer<Null, signup_db_topic_value>>(_ =>
56+
new ConsumerBuilder<Null, signup_db_topic_value>(consumerConfig)
57+
.SetKeyDeserializer(new AvroDeserializer<Null>(schemaRegistry).AsSyncOverAsync())
58+
.SetValueDeserializer(new AvroDeserializer<signup_db_topic_value>(schemaRegistry).AsSyncOverAsync())
59+
.SetOAuthBearerTokenRefreshHandler(OauthCallback).Build());
60+
```
61+
62+
#### Without ScheamRegistry
63+
64+
```cs
65+
var consumerBuilder = new ConsumerBuilder<string, string>(consumerConfig).SetOAuthBearerTokenRefreshHandler(OauthCallback).Build();
66+
67+
consumerBuilder.Subscribe("Kafka-Consumer-Topic");
68+
69+
Console.WriteLine("Kafka Start Listening...");
70+
71+
while (true)
72+
{
73+
var consumer= consumerBuilder.Consume();
74+
Console.WriteLine(consumer.Message.Value);
75+
}
76+
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
### 1. Install Required Nuget Package
2+
---
3+
4+
```
5+
- AWS.MSK.Auth
6+
- Streamiz.Kafka.Net.SchemaRegistry.SerDes.Avro
7+
```
8+
9+
### 2. Setup OAuthCallBack Function
10+
---
11+
12+
```cs
13+
var mskAuthTokenGenerator = new AWSMSKAuthTokenGenerator();
14+
15+
private void OauthCallback(IClient client, string cfg)
16+
{
17+
try
18+
{
19+
var (token, expiryMs) = mskAuthTokenGenerator.GenerateAuthToken(Amazon.RegionEndpoint.APSouth1); //Change The RegionEndpoint for Your MSK Region.
20+
client.OAuthBearerSetToken(token, expiryMs, "DummyPrincipal");
21+
}
22+
catch (Exception e)
23+
{
24+
client.OAuthBearerSetTokenFailure(e.ToString());
25+
}
26+
}
27+
```
28+
29+
### 3. ConsumerConfig Setup
30+
---
31+
32+
```cs
33+
var config = new ProducerConfig
34+
{
35+
BootstrapServers = "<HOST>:<PORT>",
36+
Acks = Acks.None,
37+
SecurityProtocol = SecurityProtocol.SaslSsl,
38+
SaslMechanism = SaslMechanism.OAuthBearer
39+
};
40+
```
41+
42+
### 4. Setup ProducerBuilder with SchemaRegistry
43+
---
44+
45+
```cs
46+
var schemaRegistryConfig = new SchemaRegistryConfig
47+
{
48+
Url = "http://<scheamRegistryHost>:<Port>";
49+
};
50+
51+
var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig);
52+
53+
service.AddSingleton<IProducer<Null, signup_db_topic_value>>(_ =>
54+
new ProducerBuilder<Null, signup_db_topic_value>(config)
55+
.SetKeySerializer(new AvroSerializer<Null>(schemaRegistry))
56+
.SetValueSerializer(new AvroSerializer<signup_db_topic_value>(schemaRegistry))
57+
.SetOAuthBearerTokenRefreshHandler(OauthCallback).Build());
58+
```
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
### Required Tools
2+
---
3+
- Helm
4+
- Kubectl
5+
- Prometheus
6+
- Loki
7+
8+
### 1. Apply Alloy Operator
9+
---
10+
```bash
11+
$ kubectl apply -f https://github.com/grafana/alloy-operator/releases/latest/download/collectors.grafana.com_alloy.yaml
12+
```
13+
14+
### 2. Add Grafana Helm Repo
15+
---
16+
```bash
17+
$ helm repo add grafana https://grafana.github.io/helm-charts
18+
$ helm repo update
19+
```
20+
21+
### 3. Create a k8s-monitoring Value File
22+
---
23+
!!! warning
24+
25+
Must Enable **--web.enable-remote-write-receiver** settings in prometheus because prometheus is Pull mode so to Push the Metrics for K8s Grafana-Alloy must enable this settings, if you forget to enable the this settings metrics will not push from Grafana-Alloy and in `grafana-k8s-monitoring-alloy-metrics` pod it will thorw Error.
26+
27+
```yaml
28+
cluster:
29+
name: <Enter Cluster Name>
30+
31+
destinations:
32+
- name: localPrometheus
33+
type: prometheus
34+
url: http://<prometheus-host>:9090/api/v1/write
35+
36+
- name: localLoki
37+
type: loki
38+
url: http://<loki-host>:3100/loki/api/v1/push
39+
40+
# enable cluster metrics
41+
clusterMetrics:
42+
enabled: true
43+
44+
# enable pod logs + node logs if you want them
45+
podLogs:
46+
enabled: true
47+
nodeLogs:
48+
enabled: false # INFO : I Disable this dude to pods error wand to enable this again and check for error, if you get pod log error set this to false.
49+
50+
# enable cluster events (optional)
51+
clusterEvents:
52+
enabled: true
53+
54+
# turn on collectors
55+
alloy-metrics:
56+
enabled: true
57+
alloy-logs:
58+
enabled: true
59+
alloy-singleton:
60+
enabled: true
61+
```
62+
63+
For more Destinations Here is Doc.
64+
65+
Main Doc : [**Link**](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/docs/destinations/README.md)
66+
67+
This section defines the destinations for your telemetry data. You can configure multiple destinations for logs,
68+
metrics, and traces. Here are the supported destination types:
69+
70+
!!! warning
71+
72+
In this Grafana k8s-Monitoring Offical Doc They not Defain the **destinations.url** in yaml properly, you must include after the destinations host and port you need to set path.
73+
74+
- `http://<prometheus-host>:<prometheus-port>` : This Will Not work, it will throw error in grafana-k8s-monitoring pod.
75+
- `http://<prometheus-host>:<prometheus-port>/<path>` : Wand to set the correct path to Push Path to send the data to destinations.
76+
77+
examples:
78+
79+
- prometheus : `http://<prometheus-host>:9090/api/v1/write`
80+
- loki : `http://<loki-host>:3100/loki/api/v1/push`
81+
82+
| Type | Protocol | Telemetry Data | Docs |
83+
|--------------|------------------|-----------------------|-------------------------------------------|
84+
| `prometheus` | Remote Write | Metrics | [Docs](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/docs/destinations/prometheus.md) |
85+
| `loki` | Loki | Logs | [Docs](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/docs/destinations/loki.md) |
86+
| `otlp` | OTLP or OTLPHTTP | Metrics, Logs, Traces | [Docs](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/docs/destinations/otlp.md) |
87+
| `pyroscope` | Pyroscope | Profiles | [Docs](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/docs/destinations/pyroscope.md) |
88+
89+
### 4. Deploy The grafana-k8s-monitoring
90+
---
91+
```bash
92+
$ helm install grafana-k8s-monitoring grafana/k8s-monitoring -n grafana -f "./values.yaml"
93+
```

mkdocs.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,21 @@ nav:
3232
- Install Using Snap:
3333
- Dotnet-Install: dotnet/linux-install/snap/dotnet-install.md
3434
- Dotnet-Tools-Install: dotnet/linux-install/snap/dotnet-tools-install.md
35+
- AWS:
36+
- MSK:
37+
- Setup-Producer: dotnet/aws/msk/setup-producer.md
38+
- Setup-Consumer: dotnet/aws/msk/setup-consumer.md
3539
- Grpcurl: grpcurl/grpcurl.md
3640
- AWS:
3741
- MSK:
3842
- setup-cp-schema-registry: aws/msk/setup-cp-schema-registry.md
3943
- EKS:
4044
- setup-karpenter: aws/eks/setup-karpenter.md
41-
- K8s:
45+
- K8S:
4246
- Debug-Commands: k8s/debug-commands.md
43-
47+
- Grafana:
48+
- K8S:
49+
- setup-k8s-monitoring: grafana/k8s/k8s-monitoring/setup-k8s-monitoring.md
4450

4551
markdown_extensions:
4652
- pymdownx.highlight:

0 commit comments

Comments
 (0)