summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch
blob: f5226fe6e1ed52ba36e58cc759e6b84e546da9a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
From 32e557279450226ed9c06312649d90b802f3d4c5 Mon Sep 17 00:00:00 2001
From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Date: Tue, 13 Apr 2021 13:00:18 +0000
Subject: [PATCH] Add support for MetricDefinition scheme

Added MetricDefinition node to Redfish code. Now user is able to list
all available metrics in OpenBMC that are supported by Telemetry
service. Metrics are grouped by reading type.

MetricDefinitions contains all physical sensors supported by redfish,
algorithm iterates through all chassis and collects results for each
node available in that chassis (Power, Thermal, Sensors).

When BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM will be enabled by
default (meson option redfish-new-powersubsystem-thermalsubsystem) it
will be possible to optimize this algorithm to only get sensors from
Sensors node. Currently Sensors node doesn't contain all available
sensors.

Tested:
 - MetricDefinitions response is filled with existing sensors, it works
   with and without Telemetry service
 - Validated a presence of MetricDefinition members and its attributes
 - Successfully passed RedfishServiceValidator.py using witherspoon
   image on QEMU
 - Tested using following GET,POST requests

GET /redfish/v1/TelemetryService/MetricDefinitions
{
  "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions",
  "@odata.type": "#MetricDefinitionCollection.MetricDefinitionCollection",
  "Members": [
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Pwm"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostCpuUtilization"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostMemoryBandwidthUtilization"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostPciBandwidthUtilization"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Inlet_BRD_Temp"
    },
    {
      "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Left_Rear_Board_Temp"
    }
  ],
  "Members@odata.count": 7,
  "Name": "Metric Definition Collection"
}

GET /redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach
{
  "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach",
  "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
  "Id": "Fan_Tach",
  "IsLinear": true,
  "MaxReadingRange": 25000.0,
  "MetricDataType": "Decimal",
  "MetricProperties": [
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/0/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/1/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/2/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/3/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/4/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/5/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/6/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/7/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/8/Reading",
    "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/9/Reading"
  ],
  "MetricType": "Gauge",
  "MinReadingRange": 0.0,
  "Name": "Fan_Tach",
  "Units": "RPM"
}

POST redfish/v1/TelemetryService/MetricReportDefinitions, body:
{
  "Id": "TestReport",
  "Metrics": [
    {
      "MetricId": "TestMetric",
      "MetricProperties": [
        "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/3/Reading",
      ]
    }
  ],
  "MetricReportDefinitionType": "OnRequest",
  "ReportActions": [
    "RedfishEvent",
    "LogToMetricReportsCollection"
  ]
}
{
  "@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "The resource has been created successfully",
      "MessageArgs": [],
      "MessageId": "Base.1.8.1.Created",
      "MessageSeverity": "OK",
      "Resolution": "None"
    }
  ]
}

Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I3086e1302e1ba2e5442d1367939fd5507a0cbc00
---
 redfish-core/include/redfish.hpp              |   3 +
 .../include/utils/get_chassis_names.hpp       |  58 +++
 .../include/utils/telemetry_utils.hpp         |   2 +
 redfish-core/lib/metric_definition.hpp        | 368 ++++++++++++++++++
 redfish-core/lib/telemetry_service.hpp        |   3 +-
 5 files changed, 433 insertions(+), 1 deletion(-)
 create mode 100644 redfish-core/include/utils/get_chassis_names.hpp
 create mode 100644 redfish-core/lib/metric_definition.hpp

diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index 0a97150..67c5af2 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -26,6 +26,7 @@
 #include "../lib/managers.hpp"
 #include "../lib/memory.hpp"
 #include "../lib/message_registries.hpp"
+#include "../lib/metric_definition.hpp"
 #include "../lib/metric_report.hpp"
 #include "../lib/metric_report_definition.hpp"
 #include "../lib/network_protocol.hpp"
@@ -200,6 +201,8 @@ class RedfishService
         requestRoutesMetricReportDefinition(app);
         requestRoutesMetricReportCollection(app);
         requestRoutesMetricReport(app);
+        requestRoutesMetricDefinitionCollection(app);
+        requestRoutesMetricDefinition(app);
     }
 };
 
diff --git a/redfish-core/include/utils/get_chassis_names.hpp b/redfish-core/include/utils/get_chassis_names.hpp
new file mode 100644
index 0000000..0276b6f
--- /dev/null
+++ b/redfish-core/include/utils/get_chassis_names.hpp
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <include/dbus_singleton.hpp>
+
+#include <array>
+#include <string>
+#include <vector>
+
+namespace redfish
+{
+
+namespace utils
+{
+
+template <typename F>
+inline void getChassisNames(F&& cb)
+{
+    const std::array<const char*, 2> interfaces = {
+        "xyz.openbmc_project.Inventory.Item.Board",
+        "xyz.openbmc_project.Inventory.Item.Chassis"};
+
+    crow::connections::systemBus->async_method_call(
+        [callback = std::move(cb)](const boost::system::error_code ec,
+                                   const std::vector<std::string>& chassis) {
+            std::vector<std::string> chassisNames;
+
+            if (ec)
+            {
+                callback(ec, chassisNames);
+                return;
+            }
+
+            chassisNames.reserve(chassis.size());
+            for (const std::string& path : chassis)
+            {
+                sdbusplus::message::object_path dbusPath = path;
+                std::string name = dbusPath.filename();
+                if (name.empty())
+                {
+                    callback(boost::system::errc::make_error_code(
+                                 boost::system::errc::invalid_argument),
+                             chassisNames);
+                    return;
+                }
+                chassisNames.emplace_back(std::move(name));
+            }
+
+            callback(ec, chassisNames);
+        },
+        "xyz.openbmc_project.ObjectMapper",
+        "/xyz/openbmc_project/object_mapper",
+        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
+        "/xyz/openbmc_project/inventory", 0, interfaces);
+}
+
+} // namespace utils
+
+} // namespace redfish
diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
index 5872350..1b4f75d 100644
--- a/redfish-core/include/utils/telemetry_utils.hpp
+++ b/redfish-core/include/utils/telemetry_utils.hpp
@@ -10,6 +10,8 @@ namespace telemetry
 
 constexpr const char* service = "xyz.openbmc_project.Telemetry";
 constexpr const char* reportInterface = "xyz.openbmc_project.Telemetry.Report";
+constexpr const char* metricDefinitionUri =
+    "/redfish/v1/TelemetryService/MetricDefinitions/";
 constexpr const char* metricReportDefinitionUri =
     "/redfish/v1/TelemetryService/MetricReportDefinitions/";
 constexpr const char* metricReportUri =
diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp
new file mode 100644
index 0000000..347c297
--- /dev/null
+++ b/redfish-core/lib/metric_definition.hpp
@@ -0,0 +1,368 @@
+#pragma once
+
+#include "async_resp.hpp"
+#include "sensors.hpp"
+#include "utils/get_chassis_names.hpp"
+#include "utils/telemetry_utils.hpp"
+
+#include <registries/privilege_registry.hpp>
+
+namespace redfish
+{
+
+namespace telemetry
+{
+
+struct ValueVisitor
+{
+    ValueVisitor(boost::system::error_code& ec) : ec(ec)
+    {}
+
+    template <class T>
+    double operator()(T value) const
+    {
+        return static_cast<double>(value);
+    }
+
+    double operator()(std::monostate) const
+    {
+        ec = boost::system::errc::make_error_code(
+            boost::system::errc::invalid_argument);
+        return double{};
+    }
+
+    boost::system::error_code& ec;
+};
+
+inline void getReadingRange(
+    const std::string& service, const std::string& path,
+    const std::string& property,
+    std::function<void(boost::system::error_code, double)> callback)
+{
+    crow::connections::systemBus->async_method_call(
+        [callback = std::move(callback)](
+            boost::system::error_code ec,
+            const std::variant<std::monostate, double, uint64_t, int64_t,
+                               uint32_t, int32_t, uint16_t, int16_t>&
+                valueVariant) {
+            if (ec)
+            {
+                callback(ec, double{});
+                return;
+            }
+
+            const double value = std::visit(ValueVisitor(ec), valueVariant);
+
+            callback(ec, value);
+        },
+        service, path, "org.freedesktop.DBus.Properties", "Get",
+        "xyz.openbmc_project.Sensor.Value", property);
+}
+
+inline void
+    fillMinMaxReadingRange(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                           const std::string& serviceName,
+                           const std::string& sensorPath)
+{
+    asyncResp->res.jsonValue["MetricType"] = "Numeric";
+
+    telemetry::getReadingRange(
+        serviceName, sensorPath, "MinValue",
+        [asyncResp](boost::system::error_code ec, double readingRange) {
+            if (ec)
+            {
+                messages::internalError(asyncResp->res);
+                return;
+            }
+
+            if (std::isfinite(readingRange))
+            {
+                asyncResp->res.jsonValue["MetricType"] = "Gauge";
+
+                asyncResp->res.jsonValue["MinReadingRange"] = readingRange;
+            }
+        });
+
+    telemetry::getReadingRange(
+        serviceName, sensorPath, "MaxValue",
+        [asyncResp](boost::system::error_code ec, double readingRange) {
+            if (ec)
+            {
+                messages::internalError(asyncResp->res);
+                return;
+            }
+
+            if (std::isfinite(readingRange))
+            {
+                asyncResp->res.jsonValue["MetricType"] = "Gauge";
+
+                asyncResp->res.jsonValue["MaxReadingRange"] = readingRange;
+            }
+        });
+}
+
+inline void getSensorService(
+    const std::string& sensorPath,
+    std::function<void(boost::system::error_code, const std::string&)> callback)
+{
+    using ResultType = std::pair<
+        std::string,
+        std::vector<std::pair<std::string, std::vector<std::string>>>>;
+
+    crow::connections::systemBus->async_method_call(
+        [sensorPath, callback = std::move(callback)](
+            boost::system::error_code ec,
+            const std::vector<ResultType>& result) {
+            if (ec)
+            {
+                callback(ec, std::string{});
+                return;
+            }
+
+            for (const auto& [path, serviceToInterfaces] : result)
+            {
+                if (path == sensorPath)
+                {
+                    for (const auto& [service, interfaces] :
+                         serviceToInterfaces)
+                    {
+                        callback(boost::system::errc::make_error_code(
+                                     boost::system::errc::success),
+                                 service);
+                        return;
+                    }
+                }
+            }
+
+            callback(boost::system::errc::make_error_code(
+                         boost::system::errc::no_such_file_or_directory),
+                     std::string{});
+        },
+        "xyz.openbmc_project.ObjectMapper",
+        "/xyz/openbmc_project/object_mapper",
+        "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+        "/xyz/openbmc_project/sensors", 2,
+        std::array{"xyz.openbmc_project.Sensor.Value"});
+}
+
+constexpr auto metricDefinitionMapping = std::array{
+    std::pair{"fan_pwm", "Fan_Pwm"}, std::pair{"fan_tach", "Fan_Tach"}};
+
+std::string mapSensorToMetricDefinition(const std::string& sensorPath)
+{
+    sdbusplus::message::object_path sensorObjectPath{sensorPath};
+
+    const auto it = std::find_if(
+        metricDefinitionMapping.begin(), metricDefinitionMapping.end(),
+        [&sensorObjectPath](const auto& item) {
+            return item.first == sensorObjectPath.parent_path().filename();
+        });
+
+    const char* metricDefinitionPath =
+        "/redfish/v1/TelemetryService/MetricDefinitions/";
+
+    if (it != metricDefinitionMapping.end())
+    {
+        return std::string{metricDefinitionPath} + it->second;
+    }
+
+    return metricDefinitionPath + sensorObjectPath.filename();
+}
+
+template <class Callback>
+inline void mapRedfishUriToDbusPath(Callback&& callback)
+{
+    utils::getChassisNames([callback = std::move(callback)](
+                               boost::system::error_code ec,
+                               const std::vector<std::string>& chassisNames) {
+        if (ec)
+        {
+            BMCWEB_LOG_ERROR << "getChassisNames error: " << ec.value();
+            callback(ec, {});
+            return;
+        }
+
+        auto counter = std::make_shared<std::pair<
+            boost::container::flat_map<std::string, std::string>, size_t>>();
+
+        auto handleRetrieveUriToDbusMap =
+            [counter, callback = std::move(callback)](
+                const boost::beast::http::status status,
+                const boost::container::flat_map<std::string, std::string>&
+                    uriToDbus) {
+                if (status != boost::beast::http::status::ok)
+                {
+                    BMCWEB_LOG_ERROR << "Failed to retrieve URI to dbus "
+                                        "sensors map with err "
+                                     << static_cast<unsigned>(status);
+                    counter->second = 0u;
+                    callback(boost::system::errc::make_error_code(
+                                 boost::system::errc::io_error),
+                             {});
+                    return;
+                }
+
+                for (const auto& [key, value] : uriToDbus)
+                {
+                    counter->first[key] = value;
+                }
+
+                if (--counter->second == 0u)
+                {
+                    callback(boost::system::errc::make_error_code(
+                                 boost::system::errc::success),
+                             counter->first);
+                }
+            };
+
+        for (const std::string& chassisName : chassisNames)
+        {
+            for (const auto& [sensorNode, dbusPaths] : sensors::dbus::paths)
+            {
+                ++counter->second;
+                retrieveUriToDbusMap(chassisName, sensorNode.data(),
+                                     handleRetrieveUriToDbusMap);
+            }
+        }
+    });
+}
+
+} // namespace telemetry
+
+inline void requestRoutesMetricDefinitionCollection(App& app)
+{
+    BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricDefinitions/")
+        .privileges(privileges::getTelemetryService)
+        .methods(boost::beast::http::verb::get)(
+            [](const crow::Request&,
+               const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+                telemetry::mapRedfishUriToDbusPath(
+                    [asyncResp](boost::system::error_code ec,
+                                const boost::container::flat_map<
+                                    std::string, std::string>& uriToDbus) {
+                        if (ec)
+                        {
+                            messages::internalError(asyncResp->res);
+                            BMCWEB_LOG_ERROR
+                                << "mapRedfishUriToDbusPath error: "
+                                << ec.value();
+                            return;
+                        }
+
+                        std::set<std::string> members;
+
+                        for (const auto& [uri, dbusPath] : uriToDbus)
+                        {
+                            members.insert(
+                                telemetry::mapSensorToMetricDefinition(
+                                    dbusPath));
+                        }
+
+                        for (const std::string& odataId : members)
+                        {
+                            asyncResp->res.jsonValue["Members"].push_back(
+                                {{"@odata.id", odataId}});
+                        }
+
+                        asyncResp->res.jsonValue["Members@odata.count"] =
+                            asyncResp->res.jsonValue["Members"].size();
+                    });
+
+                asyncResp->res.jsonValue["@odata.type"] =
+                    "#MetricDefinitionCollection."
+                    "MetricDefinitionCollection";
+                asyncResp->res.jsonValue["@odata.id"] =
+                    "/redfish/v1/TelemetryService/MetricDefinitions";
+                asyncResp->res.jsonValue["Name"] =
+                    "Metric Definition Collection";
+                asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
+                asyncResp->res.jsonValue["Members@odata.count"] = 0;
+            });
+}
+
+inline void requestRoutesMetricDefinition(App& app)
+{
+    BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricDefinitions/<str>/")
+        .privileges(privileges::getTelemetryService)
+        .methods(
+            boost::beast::http::verb::get)([](const crow::Request&,
+                                              const std::shared_ptr<
+                                                  bmcweb::AsyncResp>& asyncResp,
+                                              const std::string& name) {
+            telemetry::mapRedfishUriToDbusPath(
+                [asyncResp, name](
+                    boost::system::error_code ec,
+                    const boost::container::flat_map<std::string, std::string>&
+                        uriToDbus) {
+                    if (ec)
+                    {
+                        messages::internalError(asyncResp->res);
+                        BMCWEB_LOG_ERROR << "mapRedfishUriToDbusPath error: "
+                                         << ec.value();
+                        return;
+                    }
+
+                    std::string odataId = telemetry::metricDefinitionUri + name;
+                    boost::container::flat_map<std::string, std::string>
+                        matchingUris;
+
+                    for (const auto& [uri, dbusPath] : uriToDbus)
+                    {
+                        if (telemetry::mapSensorToMetricDefinition(dbusPath) ==
+                            odataId)
+                        {
+                            matchingUris.emplace(uri, dbusPath);
+                        }
+                    }
+
+                    if (matchingUris.empty())
+                    {
+                        messages::resourceNotFound(asyncResp->res,
+                                                   "MetricDefinition", name);
+                        return;
+                    }
+
+                    std::string sensorPath = matchingUris.begin()->second;
+
+                    telemetry::getSensorService(
+                        sensorPath,
+                        [asyncResp, name, odataId = std::move(odataId),
+                         sensorPath, matchingUris = std::move(matchingUris)](
+                            boost::system::error_code ec,
+                            const std::string& serviceName) {
+                            if (ec)
+                            {
+                                messages::internalError(asyncResp->res);
+                                BMCWEB_LOG_ERROR << "getServiceSensorFailed: "
+                                                 << ec.value();
+                                return;
+                            }
+
+                            asyncResp->res.jsonValue["Id"] = name;
+                            asyncResp->res.jsonValue["Name"] = name;
+                            asyncResp->res.jsonValue["@odata.id"] = odataId;
+                            asyncResp->res.jsonValue["@odata.type"] =
+                                "#MetricDefinition.v1_0_3.MetricDefinition";
+                            asyncResp->res.jsonValue["MetricDataType"] =
+                                "Decimal";
+                            asyncResp->res.jsonValue["IsLinear"] = true;
+                            asyncResp->res.jsonValue["Units"] =
+                                sensors::toReadingUnits(
+                                    sdbusplus::message::object_path{sensorPath}
+                                        .parent_path()
+                                        .filename());
+
+                            for (const auto& [uri, dbusPath] : matchingUris)
+                            {
+                                asyncResp->res.jsonValue["MetricProperties"]
+                                    .push_back(uri);
+                            }
+
+                            telemetry::fillMinMaxReadingRange(
+                                asyncResp, serviceName, sensorPath);
+                        });
+                });
+        });
+}
+
+} // namespace redfish
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
index 8ecc591..027b51b 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
@@ -18,11 +18,12 @@ inline void handleTelemetryServiceGet(
     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TelemetryService";
     asyncResp->res.jsonValue["Id"] = "TelemetryService";
     asyncResp->res.jsonValue["Name"] = "Telemetry Service";
-
     asyncResp->res.jsonValue["MetricReportDefinitions"]["@odata.id"] =
         "/redfish/v1/TelemetryService/MetricReportDefinitions";
     asyncResp->res.jsonValue["MetricReports"]["@odata.id"] =
         "/redfish/v1/TelemetryService/MetricReports";
+    asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] =
+        "/redfish/v1/TelemetryService/MetricDefinitions";
 
     crow::connections::systemBus->async_method_call(
         [asyncResp](const boost::system::error_code ec,
-- 
2.25.1