Monitoring on Orleans
I would like to get stats in Orleans , stats like CPU and memory usage, number of grains and any other telemetry data which can help me monitor the system and add/remove servers from my system.
Currently the old monitoring doc is almost incomplete or incorrect on every point or only talks about Azure. https://dotnet.github.io/orleans/Documentation/Deployment-and-Operations/Monitoring/Runtime-Monitoring.html
Any pointers on how can I write the silo stats or detailed statistics metrics to my own DB and also on how to get performance counters installed on the system? I know there are telemetry API but could not find any docs on them.
We've had a disaster in our servers and I'm setting out to making sure it doesn't happen again. I want to monitor the system, add and remove servers when load goes up and down and ...
If I receive some pointers I would be both glad and thankful and will help on updating the docs as before.
Hi, as a side note - can you please share some details about your disaster, maybe we could also learn from it?
@shlomiw Hey man! Well the disaster was an issue in our data center with its virtualization system or hard disks. All of our disks were working with huge delay and the data center support people messed up our VMs while trying to fix the issue and we had some downtime. It was a disaster because we didn't have monitoring so our users informed us that the servers aren't working well and secondly because finding out what is going on was hard and we had lots of offline time. We moved to the cloud (upcloud.com not due to technical reasons).
@ashkan-saeedi-mazdeh - I understand, thanks for sharing!
To get those Stats, you will need to configure a metric telemetry consumer IMetricTelemetryConsumer. currently you can configure through LogManager.TelemetryConsumers.Add(your consumer). Currently all the stats is piping to telemetry consumers.
To install perf counters, you will need to run OrleansPerformanceCounterInstaller.
I apologize for lack of documentations on that part. We are working on making it better.
@xiazen Awesome! No problem. Orleans is great and you guys are doing a great job. I've previously helped on docs (It doesn't show up in contributors but I wrote several pages). I'll update monitoring docs as soon as I get it working at my project.
That will be great !! thanks in advance !
@xiazen I see that the method takes ITelemetryConsumer which is parent of IMetricTelemetryConsumer and FileTelemetryConsumer and TraceTelemetryConsumer derive from ITelemetryConsumer and not the metric one. Can you let me know the reason?
Also where can I get the installer for perf counters? I saw a Microsoft.Orleans.OrleansTelemetryConsumers.Counters package in NuGet which probably writes to the counters but I guess we need to register them somehow right?
Thanks for the description in advance, After I receive the answers from you, Will try to update the monitoring docs
@xiazen I see that the method takes ITelemetryConsumer which is parent of IMetricTelemetryConsumer and FileTelemetryConsumer and TraceTelemetryConsumer derive from ITelemetryConsumer and not the metric one. Can you let me know the reason?
I'm not sure I understand the question. ITelemetryConsumer was introduced to record telemetry events. At the time, design decided telemetry events can be categorized into MetricTelemetry, TraceTelemetry etc. That's why there's IMetricTelemetryConsumer, which only track MetricTelemetry. Orleans support three implementations of IMetricTelemetryConsumer, which is OrleansTelemetryConsumers.Counters, OrleansTelemetryConsumers.AI, OrleansTelemetryConsumers.NewRelic. If you configure either of the three to your cluster, or your own implementation, you will be able to get metric telemetry from Orleans runtime I think.
FileTelemetryConsumer and TraceTelemetryConsumer implements ITraceTelemetryConsumer. They are designed to just record trace telemetry events. That's why they are not IMetricTelemetryConsumer.
Does that answer your question?
Also where can I get the installer for perf counters? I saw a Microsoft.Orleans.OrleansTelemetryConsumers.Counters package in NuGet which probably writes to the counters but I guess we need to register them somehow right?
You can register them through xml
<Telemetry>
<TelemetryConsumer Assembly="OrleansTelemetryConsumers.Counters" Type="OrleansTelemetryConsumers.Counters.OrleansPerfCounterTelemetryConsumer" />
</Telemetry>
Or through LogManager.TelemetryConsumer.Add(new OrleansPerfCounterTelemetryConsumer()). That will enable writing metrics into perf counters.
If you want to publish metrics into your DB as well using IMetricTelemetryConsumer , you will need to write your own IMetricTelemetryConsumer and make it write into your DB and register the consumer into your cluster, in the same fashion as you register OrleansPerfCounterTelemetryConsumer .
Let me know if this works ! !
@xiazen
I'm not sure I understand the question. ITelemetryConsumer was introduced to record telemetry events. At the time, design decided telemetry events can be categorized into MetricTelemetry, TraceTelemetry etc. That's why there's IMetricTelemetryConsumer, which only track MetricTelemetry. Orleans support three implementations of IMetricTelemetryConsumer, which is OrleansTelemetryConsumers.Counters ,
Thanks, Now I understand. I wasn't aware of existence of other telemetry providers and thought metrics is the only one. I asked this to satisfy my curiosity about the design and for writing a better documentation.
Can you let me know how many other telemetry consumers are (other than trace and metric)?
Also on counters you said
You can register them through xml ...
Well I know how to register the provider but thanks anyways. I thought that there is a separate registration process for the counters in windows which your answer implies not.
I'll write my monitoring solution and then will let you know. If things move forward as they are doing now , We'll use service fabric and will integrate telemetry to their health monitor. I'll see if @ReubenBond implemented anything on that regard or not and will talk to him.
Well I know how to register the provider but thanks anyways. I thought that there is a separate registration process for the counters in windows which your answer implies not.
Sorry I wasn't aware you are asking the process for installing counters. By my xml config comments, I was referring how to register TelemetryConsumers. But anyway, to my knowledge, since OrleansPerformanceCounterInstaller is a custom Installer, you need to run a install tool (Visual Studio Custom Action Installer or InstallUtils.exe) to install the OrleansTelemetryConsumers.Counters assembly, then OrleansPerformanceCounterInstaller will run when the assembly is installed. But I can be wrong on this, maybe @galvesribeiro knows more on this part since I remember he added the telemetry apis.
To install the counters you have 3 ways:
- InstallUtils.exe as @xiazen suggested
- OrleansCounterControl.exe
- Embed the installer (https://github.com/dotnet/orleans/blob/master/src/OrleansTelemetryConsumers.Counters/OrleansPerformanceCounterInstaller.cs) on your Silo project so you can invoke it before start the Silo. (it will require the Silo project to run with administrator permissions).
You can get a lot of what you want using the IManagementGrain. Here is a function I have that queries all silos and gets stats to send to a slack channel
private async Task<List<SlackService.SlackSection>> CreateSiloMachineStatsSections()
{
var sections = new List<SlackService.SlackSection>();
var grain = this.GrainFactory.GetGrain<IManagementGrain>(0);
var silos = await grain.GetDetailedHosts(true);
foreach (var silo in silos)
{
var siloRuntimeStatistics = (await grain.GetRuntimeStatistics(new[] { silo.SiloAddress })).First();
var cpuUsage = Math.Round(siloRuntimeStatistics.CpuUsage, 0);
var availableMemoryGb = Math.Round(siloRuntimeStatistics.AvailableMemory / 1024 / 1024 / 1024, 2);
var remainingDiskSpaceGb = Math.Round(this.GetHostDriveRemainingDiskSpace(silo.HostName) / 1024 / 1024 / 1024, 2);
var eventType = EventType.Good;
if (cpuUsage > 90 || availableMemoryGb < 0.2 || remainingDiskSpaceGb < 1)
{
eventType = EventType.Warning;
}
else if (cpuUsage > 95 || availableMemoryGb < 0.1 || remainingDiskSpaceGb < 0.5)
{
eventType = EventType.Danger;
}
if (!this.forceUpdate && this.lastSiloStatistics.ContainsKey(silo.HostName) && this.lastSiloStatistics[silo.HostName] == eventType)
{
continue;
}
this.lastSiloStatistics[silo.HostName] = eventType;
sections.Add(section);
}
return sections;
}
@chris-eaton @xiazen @galvesribeiro Thank you all 👍
@xiazen or @galvesribeiro Any of you who knows
What are the usages of IDependencyTelemetryConsumer , IEventTelemetryConsumer and IRequestTelemetryConsumer ?
I searched for references of DependencyTelemetryConsumer and and only NewRelic and AI have implemented it and seems no method called the interface methods.
Are these being used at all? To have a complete telemetry provider should I implement all of them or not?
there's no internal usage for IDependencyTelemetryConsumer , IEventTelemetryConsumer and IRequestTelemetryConsumer because the Orleans internal doesn't track those telemetry. But you as a user can use it in your application code to track Dependency, Event and Request telemetry. Just btw, those telemetry consumers are going to be deprecated in 2.0, for more details refer #3390
@xiazen just to correct your last statement. It is not going to be deprecated. They will change on 2.0.
strike out my last comments. It is still under discussion
@xiazen I saw in PRs that you are changing LogManager and @galvesribeiro said he is changing telemetry APIs for 2.0.
Does it still make sense If I create a minimal doc page describing what people should do when using these or I should postpone until 2.0 is out? After that answer we can close this issue I guess as well.
Sorry for the late reply. I think you are right, it may make more sense to document those after 2.0. They are likely to change in 2.0. Logging is going to conform with Microsoft.Extensions.Logging and telemetry API is going to be improved by @galvesribeiro .
@xiazen No problem, I'm going to document it a bit on top of the old monitoring page and mentioning the page, This is because that is at least 1-2 months away and @galvesribeiro told me his stuff might arrive on 2.1 or something like that in gitter.
I'm closing this and thank you both a bunch