AbhishekJ 4af59c5c7d Node interface metrics application server code
This commit adds code in GO language to expose Physical Function
interface device info and statistics (metrics) of a node using
REST API service.
NIC Statistics provided by Netlink.

Following APIs are implemented:
/metrics -- all statistics in OpenMetrics format

/metrics/device/{DeviceName} -- particular device statistics in
OpenMetrics format

/metrics/pci-addr/{PciAddr} -- particular pci-address statistics in
OpenMetrics format

/json/metrics -- all metrics in json format

/json/metrics/device/{DeviceName} -- particular device statistics in
json format

/json/metrics/pci-addr/{PciAddr} -- particular pci-address statistics
in json format

Test Plan:
PASS: GO linting
PASS: Unit test
PASS: Api test.
PASS: Docker image build process defined
      here [1]
PASS: Created container image of this app, pushed to local registry
      and deployed on AIO-SX lab using sample deployment file.
      Then tested the APIs and validated the results.

Story: 2010918
Task: 48794

[1]https://docs.starlingx.io/developer_resources/build_docker_image.html

Change-Id: I5229b338b9e9afff3b02fe2389cfcd0c4e0590f6
Signed-off-by: AbhishekJ <abhishek.jaiswal@windriver.com>
2023-11-29 19:10:16 +05:30

41 lines
861 B
Docker

#
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# All Rights Reserved.
#
# ARG BASE
# FROM ${BASE}
# Build Stage
FROM golang:alpine3.17 as buildstage
# Set destination for COPY
WORKDIR /app
COPY metrics-exporter-api /app/
RUN go mod download
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o /metrics-api-server
# Deploy binary which will make image size smaller
FROM alpine:latest
# Set workdir context of current path wrt image
WORKDIR /
COPY --from=buildstage /metrics-api-server /metrics-api-server
# Optional:
# To bind to a TCP port, runtime parameters must be supplied to the
# docker command.
# But we can document in the Dockerfile what ports
# the application is going to listen on by default.
# https://docs.docker.com/engine/reference/builder/#expose
EXPOSE 9110
ENTRYPOINT ["/metrics-api-server"]