imds: expose instance metadata as an io.systemd.Metrics provider
When systemd-imds is invoked as a Varlink service (via the new systemd-imds-metrics.socket), it now acts as an io.systemd.Metrics provider for systemd-report. It connects to systemd-imdsd over the existing io.systemd.InstanceMetadata interface to acquire the real data and re-exposes the detected cloud vendor plus the well-known hostname, region, zone and public IPv4/IPv6 fields as metrics in the io.systemd.InstanceMetadata.* namespace. The metrics logic lives entirely on the client side (imds-tool-metrics.c); systemd-imdsd is unchanged. Each metric is acquired on demand with a blocking call to the daemon, benefiting from its local cache. Fields that are unset or unsupported by the vendor are simply omitted. The metrics socket is statically enabled into sockets.target.wants/.
This commit is contained in:
@@ -413,6 +413,14 @@ units = [
|
||||
'file' : 'systemd-imds-import.service.in',
|
||||
'conditions' : ['ENABLE_IMDS'],
|
||||
},
|
||||
{
|
||||
'file' : 'systemd-imds-metrics.socket',
|
||||
'conditions' : ['ENABLE_IMDS'],
|
||||
},
|
||||
{
|
||||
'file' : 'systemd-imds-metrics@.service.in',
|
||||
'conditions' : ['ENABLE_IMDS'],
|
||||
},
|
||||
{
|
||||
'file' : 'systemd-importd.service.in',
|
||||
'conditions' : ['ENABLE_IMPORTD'],
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Cloud Instance Metadata Metrics
|
||||
Documentation=man:systemd-imds(1)
|
||||
DefaultDependencies=no
|
||||
Before=sockets.target
|
||||
|
||||
[Socket]
|
||||
ListenStream=/run/systemd/report/io.systemd.InstanceMetadata
|
||||
FileDescriptorName=varlink
|
||||
SocketMode=0666
|
||||
Accept=yes
|
||||
MaxConnectionsPerSource=16
|
||||
RemoveOnStop=yes
|
||||
@@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Cloud Instance Metadata Metrics
|
||||
Documentation=man:systemd-imds(1)
|
||||
DefaultDependencies=no
|
||||
Conflicts=shutdown.target initrd-switch-root.target
|
||||
Before=shutdown.target initrd-switch-root.target
|
||||
After=systemd-imdsd.socket
|
||||
|
||||
[Service]
|
||||
# Runs systemd-imds as an io.systemd.Metrics provider. It connects to
|
||||
# systemd-imdsd to acquire the actual data. Runs as root so the daemon's Polkit
|
||||
# check on io.systemd.InstanceMetadata.Get() passes.
|
||||
ExecStart={{LIBEXECDIR}}/systemd-imds
|
||||
LockPersonality=yes
|
||||
MemoryDenyWriteExecute=yes
|
||||
NoNewPrivileges=yes
|
||||
Reference in New Issue
Block a user