Add a Prometheus handler. (#591)
* Add a Prometheus handler. * Address comments
This commit is contained in:
31
examples/prometheus/Prometheus.cs
Executable file
31
examples/prometheus/Prometheus.cs
Executable file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using k8s;
|
||||
using k8s.Monitoring;
|
||||
using Prometheus;
|
||||
|
||||
namespace prom
|
||||
{
|
||||
internal class Prometheus
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var config = KubernetesClientConfiguration.BuildDefaultConfig();
|
||||
var handler = new PrometheusHandler();
|
||||
IKubernetes client = new Kubernetes(config, new DelegatingHandler[] { handler });
|
||||
|
||||
var server = new MetricServer(hostname: "localhost", port: 1234);
|
||||
server.Start();
|
||||
|
||||
Console.WriteLine("Making requests!");
|
||||
while (true)
|
||||
{
|
||||
client.ListNamespacedPod("default");
|
||||
client.ListNode();
|
||||
client.ListNamespacedDeployment("default");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
examples/prometheus/prometheus.csproj
Executable file
12
examples/prometheus/prometheus.csproj
Executable file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\KubernetesClient\KubernetesClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user