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

Create a new chart for existing metric #573

Open
ghost opened this issue May 2, 2024 · 1 comment
Open

Create a new chart for existing metric #573

ghost opened this issue May 2, 2024 · 1 comment
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented May 2, 2024

I want to add a new chart of the number of neighbours for a device. Is the proper way to do that to simply add this to settings.py? Just asking because I'm unsure about the influxdb key and also I want to add it to the existing charts, not replace the defaults.

from openwisp_monitoring.monitoring.configuration import register_chart

neighbors_chart = {
'neighbors': {
        'type': 'line',
        'title': _('Neighbors count'),
        'description': _('Number of IP neighbors detected'),
        'unit': 'devices',
        'order': 900,
        'query': {
            'influxdb': (
                "SELECT COUNT(neighbors) FROM {key} WHERE time >= '{time}' AND "
                "content_type = '{content_type}' AND object_id = '{object_id}' "
                "GROUP BY time(1d)"
            ),
        },
    }
}
register_chart('neighbors_chart', neighbors_chart)
@ghost ghost added the question Further information is requested label May 2, 2024
@nemesifier
Copy link
Member

@mips171 register_chart is meant to be used when building custom django apps.

There's also a setting for adding new chart configurations: OPENWISP_MONITORING_CHARTS.

I don't remember we store neighbors in their own "table" (technically in influxdb that's called measurements), so I am not sure neighbors can be queried like that.

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

No branches or pull requests

1 participant