Skip to content

Commit

Permalink
Add ntc-netbox-plugin-metrics-ext plugin
Browse files Browse the repository at this point in the history
Through copying it to the -deploy directory and applying manually the
needed change (see PR bellow). Adapting freeze_requirements.sh
accordingly so it's included in the wheels.

Ideally only temporarily the time to check that it's working fine.
Longer term is either
networktocode/ntc-netbox-plugin-metrics-ext#22
gets merged and a new pypi is released. Or we decide to maintain our own
fork.

Bug: T311052
Change-Id: I31a347a29d7b1e8c2e5d75eaaa0828890bbbf8af
  • Loading branch information
XioNoX committed Oct 13, 2022
1 parent babc712 commit c2ef5ab
Show file tree
Hide file tree
Showing 28 changed files with 2,666 additions and 41 deletions.
Binary file modified artifacts/artifacts.bullseye.tar.gz
Binary file not shown.
Binary file removed artifacts/artifacts.buster.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions freeze_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ REQUIREMENTS=${BASE}/requirements.txt
REQUIREMENTS_FIXED=${BASE}/frozen-requirements-${DISTRO}.txt

pip3 install -r "$REQUIREMENTS"
pip3 install ${BASE}/plugins/ntc-netbox-plugin-metrics-ext
pip3 freeze --all --local --requirement "$REQUIREMENTS_FIXED" > "$REQUIREMENTS_FIXED"
# https://github.com/pypa/pip/issues/4668
sed -i '/pkg-resources==0.0.0/d' "$REQUIREMENTS_FIXED"
Expand Down
84 changes: 43 additions & 41 deletions frozen-requirements-bullseye.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
aniso8601==7.0.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==21.4.0
attrs==22.1.0
cachetools==5.2.0
certifi==2022.6.15
cffi==1.15.0
charset-normalizer==2.0.12
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
coreapi==2.3.3
coreschema==0.0.4
cryptography==37.0.3
cryptography==38.0.1
debtcollector==2.5.0
defusedxml==0.7.1
Deprecated==1.2.13
Expand All @@ -35,35 +35,36 @@ djangorestframework==3.13.1
dnspython==1.16.0
drf-yasg==1.20.0
eventlet==0.33.1
Flask==2.1.2
Flask==2.2.2
ghp-import==2.1.0
google-api-core==2.8.2
google-api-python-client==2.51.0
google-auth==2.8.0
google-api-core==2.10.2
google-api-python-client==2.64.0
google-auth==2.12.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.56.3
googleapis-common-protos==1.56.4
graphene==2.1.9
graphene-django==2.15.0
graphql-core==2.3.2
graphql-relay==2.0.1
greenlet==1.1.2
greenlet==1.1.3.post0
gunicorn==20.1.0
httplib2==0.20.4
idna==3.3
importlib-metadata==4.11.4
idna==3.4
importlib-metadata==5.0.0
inflection==0.5.1
iso8601==1.0.2
invoke==1.7.3
iso8601==1.1.0
itsdangerous==2.1.2
itypes==1.2.0
Jinja2==3.1.2
jsonschema==3.2.0
keystoneauth1==4.6.0
lxml==4.9.0
keystoneauth1==5.0.0
lxml==4.9.1
Markdown==3.3.6
markdown-include==0.6.0
MarkupSafe==2.1.1
mergedeep==1.3.4
mkdocs==1.3.0
mkdocs==1.4.0
mkdocs-autorefs==0.4.1
mkdocs-material==8.2.11
mkdocs-material-extensions==1.0.3
Expand All @@ -72,73 +73,74 @@ mkdocstrings-python-legacy==0.2.2
msgpack==1.0.4
netaddr==0.8.0
netifaces==0.11.0
oauthlib==3.2.0
ntc-netbox-plugin-metrics-ext @ file:///deploy/plugins/ntc-netbox-plugin-metrics-ext
oauthlib==3.2.1
os-service-types==1.7.0
oslo.config==8.8.0
oslo.config==9.0.0
oslo.i18n==5.1.0
oslo.serialization==4.3.0
oslo.utils==5.0.0
oslo.serialization==5.0.0
oslo.utils==6.0.1
packaging==21.3
PasteDeploy==2.1.1
pbr==5.9.0
pbr==5.10.0
phabricator==0.9.1
Pillow==9.1.0
pip==22.1.2
pip==22.2.2
prometheus-client==0.14.1
promise==2.3
protobuf==4.21.1
protobuf==4.21.7
psycopg2-binary==2.9.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pycryptodome==3.9.9
pyeclib==1.6.1
Pygments==2.11.2
PyJWT==2.4.0
PyJWT==2.5.0
pymdown-extensions==9.3
PyMySQL==1.0.2
pynetbox==4.3.3
pyparsing==3.0.9
pyrsistent==0.18.1
python-cas==1.6.0
python-dateutil==2.8.2
python-keystoneclient==4.5.0
python-ldap==3.4.0
python-keystoneclient==5.0.1
python-ldap==3.4.3
python-magic==0.4.27
python-swiftclient==4.0.0
python-swiftclient==4.1.0
python3-openid==3.2.0
pytkdocs==0.16.1
pytz==2022.1
pytz==2022.4
PyYAML==6.0
pyyaml_env_tag==0.1
redis==4.3.3
requests==2.28.0
redis==4.3.4
requests==2.28.1
requests-oauthlib==1.3.1
rfc3986==2.0.0
rq==1.10.1
rsa==4.8
rq==1.11.1
rsa==4.9
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
Rx==1.6.1
setuptools==62.6.0
setuptools==65.4.1
singledispatch==3.7.0
six==1.16.0
social-auth-app-django==5.0.0
social-auth-core==4.2.0
sqlparse==0.4.2
stevedore==3.5.0
sqlparse==0.4.3
stevedore==4.0.0
svgwrite==1.4.2
swagger-spec-validator==2.7.4
swift==2.29.1
swagger-spec-validator==2.7.6
swift==2.30.0
tablib==3.2.1
text-unidecode==1.3
tzdata==2022.1
uritemplate==4.1.1
urllib3==1.26.9
urllib3==1.26.12
watchdog==2.1.9
Werkzeug==2.1.2
Werkzeug==2.2.2
wheel==0.34.2
wmflib==1.2.0
wrapt==1.14.1
xattr==0.9.9
zipp==3.8.0
zipp==3.9.0
4 changes: 4 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.egg-info
__pycache__
*.swp
dist
3 changes: 3 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/.pydocstyle.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pydocstyle]
convention = google
inherit = false
24 changes: 24 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[MASTER]
# Include the pylint_django plugin to avoid spurious warnings about Django patterns
load-plugins=pylint_django

# Don't cache data for later comparisons
persistent=no

[BASIC]
# Don't require docstrings for inner Meta classes (or private classes starting with _)
no-docstring-rgx=^(_|Meta$)

[MISCELLANEOUS]
# Don't currently throw warnings for TODO comments - we should eventually remove this
notes=FIXME,XXX,

[MESSAGE CONTROL]
# Disabled due to contention with Black: bad-continuation, line-too-long
# Disabled due to noise: too-few-public-methods, too-many-ancestors, too-many-instance-attributes
disable=bad-continuation,
line-too-long,
too-few-public-methods,
too-many-ancestors,
too-many-instance-attributes,
duplicate-code
40 changes: 40 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
language: python
python:
- '3.6'
- '3.7'
- '3.8'
env:
# Each version of NetBox listed here must have a corresponding directory/configuration file
# under development/netbox_<NETBOX_VER>/configuration.py
matrix:
- NETBOX_VER=v2.8.9
- NETBOX_VER=v2.9.11
- NETBOX_VER=v2.10.4

services:
- docker
# --------------------------------------------------------------------------
# Tests
# --------------------------------------------------------------------------
before_script:
- pip install invoke docker-compose
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > /tmp/get-poetry.py
- python /tmp/get-poetry.py -y --version 1.0.2
- source $HOME/.poetry/env

script:
- invoke build --python-ver $TRAVIS_PYTHON_VERSION
- invoke tests --python-ver $TRAVIS_PYTHON_VERSION
# --------------------------------------------------------------------------
# Deploy
# --------------------------------------------------------------------------
deploy:
provider: script
script: poetry config pypi-token.pypi $PYPI_TOKEN && poetry publish --build
skip_cleanup: true
on:
tags: true
branch: master
condition: $NETBOX_VER = master
python: 3.7
9 changes: 9 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
extends: default

rules:
truthy: disable
brackets: { min-spaces-inside: 0, max-spaces-inside: 1 }
braces: { min-spaces-inside: 0, max-spaces-inside: 1 }
line-length: { allow-non-breakable-inline-mappings: true, allow-non-breakable-words: true, max: 180 }
comments-indentation: disable
19 changes: 19 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Frequently Asked Questions

## NetBox already expose a metrics endpoint, why do I need another one ?

> System metrics and application level metrics are complementary with each other
> - **SYSTEM Metrics** are very useful to instrument code, track ephemeral information and get a better visibility into what is happening. (Example of metrics: nbr of requests, requests per second, nbr of exceptions, response time, etc ...) The idea is that if we have multiple NetBox instances running behind a load balancer each one will produce a different set of metrics and the monitoring system needs to collect these metrics from all running instances and aggregate them in a dashboard. NetBox exposes some system metrics by default at `localhost/metrics`.
> - **APPLICATION Metrics** are at a higher level and represent information that is the same across all instances of an application running behind a load balancer. if I have 3 instances of NetBox running, there is no point to ask each of them how many Device objects I have in the database, since they will always return the same information. In this case, the goal is to expose only 1 endpoint that can be served by any running instance.
## Do I need an API token to access the application metrics endpoint ?

> No, currently no authentication is required (or possible).
## I don't see the plugin in the API documentation, is it expected ?

> Yes, this is expected. This API endpoint is not published in the swagger documentation because it's not a REST compatible endpoint.
## Does this plugin support NetBox 2.9 ?

> Yes
15 changes: 15 additions & 0 deletions plugins/ntc-netbox-plugin-metrics-ext/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Apache Software License 2.0

Copyright (c) 2020, Network to Code, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading

0 comments on commit c2ef5ab

Please sign in to comment.