Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agent does not report inodes usage #1793

Open
nioncode opened this issue Sep 12, 2024 · 5 comments
Open

agent does not report inodes usage #1793

nioncode opened this issue Sep 12, 2024 · 5 comments

Comments

@nioncode
Copy link

Describe the bug

ops-agent seems to not collect the system.filesystem.inodes.usage metric.

To Reproduce
Steps to reproduce the behavior:

  1. Run a GCE VM with Ops Agent --version=2.48.0 and default config.
  2. Wait for metrics to show up in Cloud Monitoring.
  3. See that there are metrics for disk usage, but NOT inodes usage

Expected behavior
Inodes usage should be collected and available in Cloud Monitoring.

Environment (please complete the following information):

  • VM distro / OS: Ubuntu 24.04
  • Ops Agent version: 2.48.0
  • Ops Agent configuration: default

Additional context
It seems like the metric is explicitly filtered out in the ops-agent (see

"system.filesystem.inodes.usage",
). Is there any reason for this? Can this be overridden with a custom config?

Copy link

This issue was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Nov 15, 2024
@nioncode
Copy link
Author

Still relevant to us.

@jefferbrecht
Copy link
Member

Hi @nioncode,

That the metric is missing is intentional. The short answer is that there's no platform-side agent.googleapis.com/... metric schema defined yet for an inode metric (although there are comparable ones for e.g. GKE platform metrics); the longer answer is that we can accept this as a feature request and work to resolve that blocker so that we can get it added to the Ops Agent. We'll add an internal tracker for this and see whether we can get it prioritized.

Apologies for the lack of response so far.

@jefferbrecht jefferbrecht removed the Stale label Dec 5, 2024
@diegopvj
Copy link

diegopvj commented Jan 4, 2025

@nioncode did you solved this by any other way? I'm trying to monitor inode by creating an alert but I'm stuck in this ops agents problem too.

@nioncode
Copy link
Author

nioncode commented Jan 7, 2025

@diegopvj yes, we created a custom python script to publish the inodes data of the mountpoint that was relevant to us. We then call this script on our GCP VMs via a systemd timer every minute.

import argparse
import subprocess
import time

from google.api import metric_pb2 as ga_metric
from google.cloud import monitoring_v3

INODE_USAGE_METRIC_TYPE = "workload.googleapis.com/inodes_percent_used"


def create_inode_usage_metric(project_id):
    client = monitoring_v3.MetricServiceClient()
    project_name = f"projects/{project_id}"

    descriptor = ga_metric.MetricDescriptor()
    descriptor.display_name = "Inode Usage"
    descriptor.description = "Tracks the percentage of used inodes on a disk"
    descriptor.type = INODE_USAGE_METRIC_TYPE
    descriptor.metric_kind = ga_metric.MetricDescriptor.MetricKind.GAUGE
    descriptor.value_type = ga_metric.MetricDescriptor.ValueType.DOUBLE
    descriptor.unit = "%"

    client.create_metric_descriptor(name=project_name, metric_descriptor=descriptor)


def report_inode_usage(project_id, instance_id, instance_zone, used_inodes_percentage):
    client = monitoring_v3.MetricServiceClient()
    project_name = f"projects/{project_id}"

    series = monitoring_v3.TimeSeries()
    series.metric.type = INODE_USAGE_METRIC_TYPE
    series.resource.type = "gce_instance"
    series.resource.labels["instance_id"] = instance_id
    series.resource.labels["zone"] = instance_zone

    interval = monitoring_v3.TimeInterval({"end_time": {"seconds": int(time.time())}})
    point = monitoring_v3.Point(
        {"interval": interval, "value": {"double_value": used_inodes_percentage}}
    )
    series.points = [point]
    client.create_time_series(name=project_name, time_series=[series])


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Send the 'inode usage' metric to Google Cloud Monitoring."
    )
    parser.add_argument("project_id", type=str, help="GC Project ID")
    parser.add_argument("instance_id", type=str, help="GC Instance ID")
    parser.add_argument("instance_zone", type=str, help="GC Instance zone")
    parser.add_argument(
        "-c", "--create", action="store_true", help="Create the 'inode usage' metric"
    )

    args = parser.parse_args()

    if args.create:
        create_inode_usage_metric(args.project_id)
    else:
        space_usage = (
            subprocess.check_output(
                "df /mnt/storage --output=itotal,iused | tail -n 1",
                shell=True,
            )
            .decode()
            .strip()
        )
        total_inodes = int(space_usage.split()[0])
        used_inodes = int(space_usage.split()[1])
        inode_usage = (used_inodes / total_inodes) * 100
        report_inode_usage(
            args.project_id, args.instance_id, args.instance_zone, inode_usage
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants