I am trying to write a dashboard in Angular for metrics generated by DropWizard. The json (partial snnipet) returned by metrics is
[ {
'gauges': {
'TaskPoolService.converter': {
'value': {
'poolSize': 4,
'completedTaskCount': 153,
'taskCount': 234
}
},
'TaskPoolService.loader': {
'value': {
'poolSize': 4,
'completedTaskCount': 473,
'taskCount': 474
}
.... (many more) .....
} ]
I want to convert it into model for use in template
class Guage {
metricName: string;
poolSize: number;
completedTaskCount: number;
taskCount: number;
}
The above json should converted into following array
[
{
metricName: 'TaskPoolService.converter',
poolSize: 4,
completedTaskCount: 153,
taskCount: 234
},
{
metricName: 'TaskPoolService.loader',
poolSize: 4,
completedTaskCount: 473,
taskCount: 474
}];
I have shown only the partial listing of metrics in json and there may be many more metrics. And also, the new metrics may get added dynamically. In other words, metric name is not constant.
Is it possible to convert the property name (which is dynamic) such as TaskPoolService.converter into metricName: 'TaskPoolService.converter'
if not possible, whether json array can be referred in template directly as key, value pair in ngFor loop so that {{ key }} can output as TaskPoolService.converter