From 20c0d60f1a9225a977a3ea2cc6181f2256712ad5 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 22 Nov 2022 22:10:06 +0530 Subject: [PATCH 01/18] Supporting v2 of DCT APIs - Added Exception Handling - Added Retries for Network calls - Reorganize the structure - Make file addition - CONTRIBUTING.md update --- .gitignore | 3 ++ CONTRIBUTING.md | 21 ++++++-- Makefile | 93 ++++++++++++++++++++++++++++++++ dct_nr_config.ini | 18 +++++++ dlpx_dct_to_nr.py | 51 ------------------ requirements.txt | 9 ++++ setup.py | 44 +++++++++++++++ src/__init__.py | 5 ++ src/main.py | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 324 insertions(+), 54 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 dct_nr_config.ini delete mode 100644 dlpx_dct_to_nr.py create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 src/__init__.py create mode 100644 src/main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4ec2c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +venv/ +venv-38/ +.idea/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fb31673..c0c8e2a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,23 @@ +# +# Copyright (c) 2021 by Delphix. All rights reserved. +# + ## Contributing 1. Fork the project. - 1. Make your bug fix or new feature. - 1. Add tests for your code. - 1. Send a pull request. + 2. Create a virtual environment with `Python 3.8` + - Pre Requisite is that you have `Python 3.8` already installed + - You can the run the below command to check that + + # python3.8 -V + output: 3.8.8 + + 3. Use Make command to create the environment. + `make env` + 4. Configure the values of API Keys and DCT URL in the `dct_nr_config.ini` file + 5. Run the script using command `make run` + 6. Make your bug fix or new feature. + 7. Add tests for your code. + 8. Send a pull request. Contributions must be signed as `User Name `. Make sure to [set up Git with user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). Bug fixes should branch from the current stable branch. New features should be based on the release branch. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8d707c8 --- /dev/null +++ b/Makefile @@ -0,0 +1,93 @@ +# +# Copyright (c) 2022 by Delphix. All rights reserved. +# +.PHONY: --check_python --check_env_exists run tests --create_virtual_env --install_dependencies env clean_build clean_env clean build + +ROOT_DIR := $(shell pwd) +VENV := venv +PYTHON := $(VENV)/bin/python +PIP := $(VENV)/bin/pip +DLPX_NR := $(ROOT_DIR)/dist/delphix-nr + +define show_version + @export LC_ALL=en_AU.UTF-8; $(DLPX_NR) --version +endef + +define check_python_exists + @if ! command -v python3.8 -V >/dev/null 2>&1; then \ + echo "Python 3.8 is NOT present on the system, Please install it"; \ + exit 1; \ + fi +endef + + +--check_python: + @# Help: Checks existence of python virtual environment + $(call check_python_exists) + +--check_env_exists: --check_python + @[ -f $(PYTHON) ] && echo $(PYTHON) exists || (echo $(PYTHON) does NOT exist, use \"make env\" to create a virtual env; exit 1) + + +run: --check_env_exists + @# Help: Takes care of checking the prequisites like python, virtual env, dependencies and at last shows the Python Version + -@echo `$(PYTHON) -V` + export PYTHONPATH=$(ROOT_DIR); $(PYTHON) src/main.py + +tests: + @# Help: Runs the unit tests inside tests folder and create a report + $(PYTHON) -m pytest tests -s -v + +--create_virtual_env: --check_python + @# Help: Creates a virtual environment + -@echo 'Creating Virtual environment' + @python3.8 -m venv venv || echo 'Python env already exists' + +--install_dependencies: requirements.txt + @# Help: Installs the dependencies from requirements.txt + -@echo 'Installing Dependencies...' + @$(PYTHON) -m pip install --upgrade pip + @$(PIP) install -r requirements.txt + +env: --create_virtual_env --install_dependencies + @# Help: Creates a virtual environment with python3.8 if not already present and activates it + +clean_env: + @# Help: Clean the virtual env that was created + -@$(VENV)/bin/pre-commit uninstall + -@rm -rf venv + +clean_build: + @# Help: Cleans the build files + -@rm -rf build/ + -@rm -rf dist/ + -@rm -rf delphix-nr.spec + +clean: clean_build + @# Help: Cleans the pycache, coverage and build files + -@rm -rf __pycache__ + -@rm -f .coverage + -@rm -rf .pytest_cache + -@rm -rf tests/.pytest_cache + -@rm -rf tests/plugin_operations/.pytest_cache + -@rm -rf tests/CodeCoverage + -@rm -rf tests/Report.html + -@rm -rf .dvp-gen-output + +build: --check_env_exists clean_build + @# Help: Makes the delphix-nr build + $(VENV)/bin/pyinstaller --onefile setup.py -n delphix-nr + -@echo 'Build is present at $(ROOT_DIR)/dist/delphix-nr' + $(call show_version) + + +# A hidden target +.hidden: +help: + @printf "%-20s %s\n" "Target" "Description" + @printf "%-20s %s\n" "------" "-----------" + @make -pqR : 2>/dev/null \ + | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \ + | sort \ + | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \ + | xargs -I _ sh -c 'printf "%-20s " _; make _ -nB | (grep -i "^# Help:" || echo "") | tail -1 | sed "s/^# Help: //g"' diff --git a/dct_nr_config.ini b/dct_nr_config.ini new file mode 100644 index 0000000..d4157d6 --- /dev/null +++ b/dct_nr_config.ini @@ -0,0 +1,18 @@ +[DCT] +DCT_HOST_URL = dct-nr.dlpxdc.co + +[API_KEYS] +DCT_API_KEY = apk 1.z2XcAcVhMHgmkEQpXfW7RCDMSqIWvSTPciIB7gJEJujeYsbJNnAABEobDK1Y6DyJ +NEW_RELIC_INSERT_KEY = 48ea98ab8d519b553344ec6d5454b82388ebNRAL + +[COMPONENTS] +; This list holds the components for which +; we send the data to new relic +; refer to DCT API's for getting these components +monitor = management/engines, sources, dsources, vdbs, environments, connections + +[INTERVAL] +seconds = 30 + +[LOGGING] +LEVEL = INFO diff --git a/dlpx_dct_to_nr.py b/dlpx_dct_to_nr.py deleted file mode 100644 index 504a9b3..0000000 --- a/dlpx_dct_to_nr.py +++ /dev/null @@ -1,51 +0,0 @@ -import os -import requests -import json -import sys -import time -from newrelic_telemetry_sdk import Event, EventClient -from requests.packages.urllib3.exceptions import InsecureRequestWarning - -requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - -DLPX_TYPES= ["engines","sources","dsources","vdbs","environments"] -# -# Request Headers ... -# -req_headers = { - 'Authorization': 'apk 2.bnQDDx46Z4CDlIShLw2ZHElWLyKtsmZaBjbQPjui8LcQ3TELbkdEbQJSki6vmwLf' -} - -# -# Python session, also handles the cookies ... -# -session = requests.session() - -# -# Login ... -# -os.environ['NEW_RELIC_INSERT_KEY'] = "87a453b2efe4bd4df78b167e7ac457e076c7NRAL" -print ('') -for i in DLPX_TYPES: - - response = requests.get('https://localhost:443/v1/'+i, headers=req_headers, verify=False) - responsej = json.loads(response.text) - print("") - print("") - print("**********************************************************************************************************************************") - event_client = EventClient(os.environ["NEW_RELIC_INSERT_KEY"]) - NEWRELIC_TYPE="Delphix " + str(i) - print (NEWRELIC_TYPE) - for line in responsej['items']: - event = Event( - NEWRELIC_TYPE, line - ) - print (event) - response = event_client.send(event) - response.raise_for_status() - print("Event sent successfully!") - print("") - -print ('') -sys.exit(0) - diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f12f83f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +# +# Copyright (c) 2022 by Delphix. All rights reserved. +# + +newrelic-telemetry-sdk==0.4.3 +pyinstaller==5.6.2 +requests==2.28.1 +tenacity==8.1.0 +urllib3==1.26.12 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..70ad506 --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +# +# Copyright (c) 2021,2022 by Delphix. All rights reserved. +# + +from setuptools import find_packages +from setuptools import setup +from src.main import VERSION + +# Get the long description from the README file +long_description = "This is an executable for Delphix New Relic Integration" + +setup( + version=VERSION, + packages=find_packages(), + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Customers", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Monitoring", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8" + ], + install_requires=[ + "newrelic-telemetry-sdk==0.4.3", + "requests==2.28.1", + "tenacity==8.1.0", + ], + # Format is mypkg.mymodule:the_function' + entry_points=""" + [console_scripts] + nr=src.main + """, + author="Delphix Engineering", + keywords="new-relic, delphix, dct", # noqa + license="Apache 2", + description="Delphix New Relic Integration", + dependency_links=[], + name="delphix-nr", + long_description_content_type="text/markdown", + long_description=long_description, + include_package_data=True, + project_urls={}, # Optional +) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..4e2c3f6 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,5 @@ +# +# Copyright (c) 2022 by Delphix. All rights reserved. +# + +VERSION = "1.0.0" diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..e5889e0 --- /dev/null +++ b/src/main.py @@ -0,0 +1,134 @@ +# +# Copyright (c) 2022 by Delphix. All rights reserved. +# + +""" +This python script takes care of sending the data +from DCT APIs for a set of components to New relic. +It can be run using Python 3.8 +""" +import datetime +import os.path +import sys +import time + +import newrelic_telemetry_sdk.client +import requests +import logging +import urllib3 +import configparser +import tenacity + +from newrelic_telemetry_sdk import Event, EventClient +from urllib3.exceptions import InsecureRequestWarning +from src import VERSION + +urllib3.disable_warnings(InsecureRequestWarning) + +config_file = "dct_nr_config.ini" +config = configparser.ConfigParser() + +if not os.path.exists(config_file): + raise Exception("Config file is required. " + "Please add dct_nr_config.ini in the current directory") + +config.read_file(open("dct_nr_config.ini")) +keys = config['API_KEYS'] +dct = config['DCT'] +config_log_level = config['LOGGING']['LEVEL'] +INTERVAL = int(config['INTERVAL']['seconds']) + +formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' +logging_levels = { + 'INFO': logging.INFO, + 'DEBUG': logging.DEBUG, + 'WARN': logging.WARNING, + 'ERROR': logging.ERROR +} +logging.basicConfig(level=logging_levels[config_log_level], format=formatter) + + +DCT_URL = dct['DCT_HOST_URL'] +DCT_API_URL = f'https://{DCT_URL}/v2/' +DLPX_TYPES = [i.strip() for i in config['COMPONENTS']['monitor'].split(',')] + +# Request Headers ... +req_headers = { + 'Authorization': keys['DCT_API_KEY'] # noqa +} + +# Python session, also handles the cookies ... +session = requests.session() + + +@tenacity.retry( + retry=tenacity.retry_if_exception_type( + newrelic_telemetry_sdk.client.HTTPError + ), + stop=tenacity.stop_after_attempt(5), + wait=tenacity.wait_fixed(5), + before_sleep=tenacity.before_sleep_log(logging, logging.INFO), +) +def send_event(event): + logging.info(event) + event_client = EventClient(keys['NEW_RELIC_INSERT_KEY']) + response = event_client.send(event) + response.raise_for_status() + logging.info("Event sent successfully!\n") + + +@tenacity.retry( + retry=tenacity.retry_if_exception_type( + AssertionError + ), + stop=tenacity.stop_after_attempt(5), + wait=tenacity.wait_fixed(5), + before_sleep=tenacity.before_sleep_log(logging, logging.DEBUG), +) +def get_data_from_dct(component): + response = requests.get(DCT_API_URL + component, + headers=req_headers, verify=False) + assert response.status_code == 200 + response_json = response.json() + return response_json + + +def push_data(): + while True: + logging.info('*' * 70) + logging.info("Pushing Data to New Relic at %s", + datetime.datetime.now()) + logging.info('*' * 70) + for i in DLPX_TYPES: + response_json = get_data_from_dct(i) + + NEWRELIC_TYPE = "Delphix " + str(i).split('/')[-1] + logging.info("Sending Data for %s \n", NEWRELIC_TYPE) + for line in response_json['items']: + event = Event( + NEWRELIC_TYPE, line + ) + send_event(event) + + logging.info(f"Sleeping for %s seconds before pushing again", INTERVAL) + logging.info('-' * 70) + time.sleep(INTERVAL) + + +def run(): + if len(sys.argv) > 1: + if sys.argv[1] == "--version": + print(VERSION) + else: + logging.info('#' * 70) + logging.info("Staring to Push Data to New Relic") + logging.info('#' * 70) + logging.debug(f"{DCT_URL=}") + logging.debug(f"{DLPX_TYPES=}") + logging.debug(f"{req_headers=}") + logging.debug(f"NEW_RELIC_INSERT_KEY = {keys['NEW_RELIC_INSERT_KEY']}") + push_data() + + +if __name__ == '__main__': + run() From e632685ec4d3f93b9721c69a298287b2d1d5bf75 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 22 Nov 2022 22:10:06 +0530 Subject: [PATCH 02/18] Supporting v2 of DCT APIs - Added Exception Handling - Added Retries for Network calls - Reorganize the structure - Make file addition - CONTRIBUTING.md update --- dct_nr_config.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dct_nr_config.ini b/dct_nr_config.ini index d4157d6..f4bff16 100644 --- a/dct_nr_config.ini +++ b/dct_nr_config.ini @@ -1,9 +1,9 @@ [DCT] -DCT_HOST_URL = dct-nr.dlpxdc.co +DCT_HOST_URL = [API_KEYS] -DCT_API_KEY = apk 1.z2XcAcVhMHgmkEQpXfW7RCDMSqIWvSTPciIB7gJEJujeYsbJNnAABEobDK1Y6DyJ -NEW_RELIC_INSERT_KEY = 48ea98ab8d519b553344ec6d5454b82388ebNRAL +DCT_API_KEY = +NEW_RELIC_INSERT_KEY = [COMPONENTS] ; This list holds the components for which From b4a66ec2a327b405e0f297b6f1c363b25bc722a7 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 22 Nov 2022 22:38:04 +0530 Subject: [PATCH 03/18] change the monitor components --- dct_nr_config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dct_nr_config.ini b/dct_nr_config.ini index f4bff16..febaf21 100644 --- a/dct_nr_config.ini +++ b/dct_nr_config.ini @@ -9,7 +9,7 @@ NEW_RELIC_INSERT_KEY = ; This list holds the components for which ; we send the data to new relic ; refer to DCT API's for getting these components -monitor = management/engines, sources, dsources, vdbs, environments, connections +monitor = management/engines, sources, dsources, vdbs, environments [INTERVAL] seconds = 30 From 9fded854062e9a34d41f79658b447bdb8fd474cc Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 22 Nov 2022 22:43:33 +0530 Subject: [PATCH 04/18] change logging levels of some logging lines --- src/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index e5889e0..958f744 100644 --- a/src/main.py +++ b/src/main.py @@ -70,11 +70,11 @@ before_sleep=tenacity.before_sleep_log(logging, logging.INFO), ) def send_event(event): - logging.info(event) + logging.debug(event) event_client = EventClient(keys['NEW_RELIC_INSERT_KEY']) response = event_client.send(event) response.raise_for_status() - logging.info("Event sent successfully!\n") + logging.debug("Event sent successfully!\n") @tenacity.retry( From 58f55a57b5683a3ecdb7d1783310751608c7aefd Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 23 Nov 2022 17:45:57 +0530 Subject: [PATCH 05/18] Correct the error in Make build --- Makefile | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8d707c8..ee4fbe0 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ clean: clean_build build: --check_env_exists clean_build @# Help: Makes the delphix-nr build - $(VENV)/bin/pyinstaller --onefile setup.py -n delphix-nr + $(VENV)/bin/pyinstaller --onefile src/main.py -n delphix-nr -@echo 'Build is present at $(ROOT_DIR)/dist/delphix-nr' $(call show_version) diff --git a/setup.py b/setup.py index 70ad506..512572e 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # Format is mypkg.mymodule:the_function' entry_points=""" [console_scripts] - nr=src.main + nr=src.main:run """, author="Delphix Engineering", keywords="new-relic, delphix, dct", # noqa From c8bcd4422ad56032b094e48cd56d05cf65472abb Mon Sep 17 00:00:00 2001 From: Nick Mathison <114104601+nick-mathison@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:34:24 -0500 Subject: [PATCH 06/18] [HUBS-1291] Readme, schedule event, standard input params - Attempt #1 (#3) * Various Updates - Remove MC mentions - Specify Env Variables for Input. Clear error response. - Clean up config and installation directions * /v2 changes + management/engines API change * NR Key, Logs, Insecure Warning, Readme * minor readme * Revert python changes * Update dlpx_dct_to_nr.py * Update README.md --- README.md | 115 +++++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index e9b8ad1..ba12d6e 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,58 @@ -# Delphix Data Control Tower MultiCloud integration with New Relic +# Delphix Data Control Tower's Integration with New Relic -This project will allow you to send data from [Delphix Data Control Tower Multicloud](https://docs.delphix.com/dctmc) to [New Relic](https://newrelic.com/) as events. DCT Multicloud is a tool that will allow you to connect to all your Delphix engines on premises or in the cloud (AWS, Azure, Google Cloud, OCI and IBM) +This project will allow you to send data from [Delphix Data Control Tower (DCT)](https://delphix.document360.io/dct/docs) to [New Relic](https://newrelic.com/) through the Events API. This repository is one component of the Delphix Quickstart. You can learn more on the [Delphix Instant Observability page](https://newrelic.com/instant-observability/delphix). ![Screenshot](images/image2.png) ## Getting Started -These instructions will provide the code you need to extract data from DCT Multicloud and send it to New Relic. +These instructions will provide the information you need to extract data from DCT and send it to New Relic. The Python script can run from any location with access to both DCT and New Relic. ### Prerequisites -It's assumed that you have a New Relic valid account and one or many [Delphix Engines registered in DCT Multicloud](https://docs.delphix.com/dctmc/connecting-a-delphix-engine). -DCT Multicloud will extract data from the Delphix Engines and we will use [New Relic Telemetry SDK](https://docs.newrelic.com/docs/telemetry-data-platform/ingest-apis/telemetry-sdks-report-custom-telemetry-data/) to send that data to New Relic. -For this project, we will use the [Python SDK](https://github.com/newrelic/newrelic-telemetry-sdk-python), however you can use any of the available SDKs in different languages. +* New Relic Account: [Sign Up](https://newrelic.com/signup) +* Delphix Data Control Tower (DCT) with one or more engines: [Data Control Tower Docs](https://delphix.document360.io/dct/docs) +* Python 3.8+: [Python Install](https://www.python.org/downloads) +* This [GitHub repository](https://github.com/delphix/dct-newrelic-integration) +Note: If you are using Windows, `py` may be specified instead of `python`. -### Installing -To push the data from Delphix DCT Multicloud to New Relic, we use the script ```dlpx_dct_to_nr.py```. -To use this script we have to do some steps first: +### Setup +The ```src/main.py``` script contains the logic to perform the data upload. However, you must do some configuration first. -* Generate the [keys to connect to DCT Multicloud](https://docs.delphix.com/dctmc/authentication) -* Generate the [New Relic access key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) +#### Package Installation +Run the following 2 pip installation commands to install the required Python packages: +```python -m pip install requests``` +```python -m pip install newrelic_telemetry_sdk``` -Once we have these keys we need to replace them in the script: +#### Required Variable Configuration +Retrieve the following: +* Record the DCT URL. +* Generate a [DCT API Key](https://delphix.document360.io/docs/authentication +* Generate a [New Relic INGEST - LICENSE Key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key). -* In req_headers we replace the DCT Multicloud key -* In NEW_RELIC_INSERT_KEY we replace the New Relic access key +Once we have these values, specify the following environment variables: +* DCT_URL +* DCT_KEY +* NEW_RELIC_KEY -This is the script: +Note: You may modify the Python script directly, but it is best practice to specify sensitive data through environment variables. -``` -import os -import requests -import json -import sys -import time -from newrelic_telemetry_sdk import Event, EventClient -from requests.packages.urllib3.exceptions import InsecureRequestWarning - -requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - -DLPX_TYPES= ["engines","sources","dsources","vdbs","environments"] -# -# Request Headers ... -# -req_headers = { - 'Authorization': 'apk 2.bnQDDx46Z4CDlIShLw2ZHElWLyKtsmZaBjbQPjui8LcQ3nELbkdEbQJSki6vmwLf' -} - -# -# Python session, also handles the cookies ... -# -session = requests.session() - -# -# Login ... -# -os.environ['NEW_RELIC_INSERT_KEY'] = "87a453b2efe4nd4df78b167e7ac457e076c7NRAL" -print ('') -for i in DLPX_TYPES: - - response = requests.get('https://localhost:443/v1/'+i, headers=req_headers, verify=False) - responsej = json.loads(response.text) - print("") - print("") - print("**********************************************************************************************************************************") - event_client = EventClient(os.environ["NEW_RELIC_INSERT_KEY"]) - NEWRELIC_TYPE="Delphix " + str(i) - print (NEWRELIC_TYPE) - for line in responsej['items']: - event = Event( - NEWRELIC_TYPE, line - ) - print (event) - response = event_client.send(event) - response.raise_for_status() - print("Event sent successfully!") - print("") - -print ('') -sys.exit(0) -``` +#### Optional Variable Configuration +Some variables, such as Components, Interval, and Logging variables, are set by default in the `dct_nr_config.ini` file. These can be updated to modify which APIs to call, how long to wait between syncs, or logging level. + +### Execution + +You may test the script by running the following command: +```python src/main.py``` + +In production, it is common to use a scheduler, such as a systemd, nohup, or wininit.exe, to ensure the script continually runs. For example, the following nohup command will run the script every N seconds based on the Interval provided in the `dct_nr_config.ini` file: +```nohup python src/main.py &``` -On execution, this script will extract data from all the registered Delphix Engines for the following metrics: +On each execution, this script will extract the following metrics from all registered Delphix engines: * Engines - Data extraction date, CPU Count, Storage, Memory, Engine Type, Version, etc. * Environments - Data extraction date, Status, Engine ID, Name, etc. @@ -93,12 +60,12 @@ On execution, this script will extract data from all the registered Delphix Engi * dSources - Data extraction date, dSource Creation Date, dSource Type, Version, Name, Status, Size, etc. * VDBs - Data extraction date, Database Type and Version, Creation Date, Group Name, Name, Parent ID, Size, Status, etc. -This script can be added to cron or any scheduler to run in any time interval. Once the data is available in New Relic, it can be used to be queried or to create dashboards. +## Data, Dashboards, and Alerts -## Data and Dashboards +Once the data is available within New Relic, you are free to leverage it as you wish through customized Dashboards and Alerts. Samples can be found as a part of the [Delphix Quickstart](https://newrelic.com/instant-observability/delphix). -This is how the raw data looks like in the [Query your data](https://docs.newrelic.com/docs/query-your-data/explore-query-data/get-started/introduction-querying-new-relic-data/#browse-data) window for the VDB metric: +As an example, this is how the raw data looks like in the [Query your data](https://docs.newrelic.com/docs/query-your-data/explore-query-data/get-started/introduction-querying-new-relic-data/#browse-data) window for the VDB metric: ![Screenshot](images/image1.png) @@ -123,9 +90,9 @@ Please read [CONTRIBUTING.md](https://github.com/delphix/.github/blob/master/CON We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). -## Reporting Issues +## Reporting Issues and Questions -Issues should be reported in the GitHub repo's issue tab. Include a link to it. +Please report all issues and questions in the [GitHub issue tab](https://github.com/delphix/dct-newrelic-integration/issues) or [Delphix Community page](https://community.delphix.com/home). Please include a complete problem description, error logs if appropriate, and directions on how to reproduce. ## Statement of Support @@ -146,4 +113,4 @@ License See the License for the specific language governing permissions and limitations under the License. ``` -Copyright (c) 2014, 2016 by Delphix. All rights reserved. +Copyright (c) 2021, 2022 by Delphix. All rights reserved. From 54143c327a0000ea9f5ac0608578c216868362a6 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 6 Dec 2022 13:06:04 +0530 Subject: [PATCH 07/18] Add support for Env variables --- .gitignore | 2 ++ dct_nr_config.ini | 7 ------- src/main.py | 29 ++++++++++++++++++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index d4ec2c3..bddc6d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ venv/ venv-38/ .idea/ +/venv3.9/ +/venv3.10/ diff --git a/dct_nr_config.ini b/dct_nr_config.ini index febaf21..82cf47d 100644 --- a/dct_nr_config.ini +++ b/dct_nr_config.ini @@ -1,10 +1,3 @@ -[DCT] -DCT_HOST_URL = - -[API_KEYS] -DCT_API_KEY = -NEW_RELIC_INSERT_KEY = - [COMPONENTS] ; This list holds the components for which ; we send the data to new relic diff --git a/src/main.py b/src/main.py index 958f744..b91ed16 100644 --- a/src/main.py +++ b/src/main.py @@ -33,8 +33,6 @@ "Please add dct_nr_config.ini in the current directory") config.read_file(open("dct_nr_config.ini")) -keys = config['API_KEYS'] -dct = config['DCT'] config_log_level = config['LOGGING']['LEVEL'] INTERVAL = int(config['INTERVAL']['seconds']) @@ -48,13 +46,22 @@ logging.basicConfig(level=logging_levels[config_log_level], format=formatter) -DCT_URL = dct['DCT_HOST_URL'] -DCT_API_URL = f'https://{DCT_URL}/v2/' +DCT_HOST_URL = os.environ.get('DCT_HOST_URL') +DCT_API_KEY = os.environ.get('DCT_API_KEY') +NEW_RELIC_INSERT_KEY = os.environ.get('NEW_RELIC_INSERT_KEY') + +if (DCT_HOST_URL and DCT_API_KEY and NEW_RELIC_INSERT_KEY) is None: + raise Exception("Please add the below keys as environment variables: " + "\n1. DCT_HOST_URL" + "\n2. DCT_API_KEY" + "\n3. NEW_RELIC_INSERT_KEY") + +DCT_API_URL = f'https://{DCT_HOST_URL}/v2/' DLPX_TYPES = [i.strip() for i in config['COMPONENTS']['monitor'].split(',')] # Request Headers ... req_headers = { - 'Authorization': keys['DCT_API_KEY'] # noqa + 'Authorization': DCT_API_KEY # noqa } # Python session, also handles the cookies ... @@ -71,7 +78,7 @@ ) def send_event(event): logging.debug(event) - event_client = EventClient(keys['NEW_RELIC_INSERT_KEY']) + event_client = EventClient(NEW_RELIC_INSERT_KEY) response = event_client.send(event) response.raise_for_status() logging.debug("Event sent successfully!\n") @@ -102,11 +109,11 @@ def push_data(): for i in DLPX_TYPES: response_json = get_data_from_dct(i) - NEWRELIC_TYPE = "Delphix " + str(i).split('/')[-1] - logging.info("Sending Data for %s \n", NEWRELIC_TYPE) + new_relic_type = "Delphix " + str(i).split('/')[-1] + logging.info("Sending Data for %s \n", new_relic_type) for line in response_json['items']: event = Event( - NEWRELIC_TYPE, line + new_relic_type, line ) send_event(event) @@ -123,10 +130,10 @@ def run(): logging.info('#' * 70) logging.info("Staring to Push Data to New Relic") logging.info('#' * 70) - logging.debug(f"{DCT_URL=}") + logging.debug(f"{DCT_HOST_URL=}") logging.debug(f"{DLPX_TYPES=}") logging.debug(f"{req_headers=}") - logging.debug(f"NEW_RELIC_INSERT_KEY = {keys['NEW_RELIC_INSERT_KEY']}") + logging.debug(f"NEW_RELIC_INSERT_KEY = {NEW_RELIC_INSERT_KEY}") push_data() From 3c6a3a7b9606c42af959e20286b487b5540e9ff5 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 6 Dec 2022 15:50:17 +0530 Subject: [PATCH 08/18] Added support for Handling Paginated response from DCT --- src/main.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index b91ed16..c2c1f9e 100644 --- a/src/main.py +++ b/src/main.py @@ -57,6 +57,7 @@ "\n3. NEW_RELIC_INSERT_KEY") DCT_API_URL = f'https://{DCT_HOST_URL}/v2/' +QUERY = '?limit=1000' DLPX_TYPES = [i.strip() for i in config['COMPONENTS']['monitor'].split(',')] # Request Headers ... @@ -92,11 +93,23 @@ def send_event(event): wait=tenacity.wait_fixed(5), before_sleep=tenacity.before_sleep_log(logging, logging.DEBUG), ) -def get_data_from_dct(component): - response = requests.get(DCT_API_URL + component, - headers=req_headers, verify=False) +def get_data_from_dct(component, query=QUERY): + url = DCT_API_URL + component + query + response = requests.get(url, headers=req_headers, verify=False) assert response.status_code == 200 response_json = response.json() + records = response_json['response_metadata']['total'] + logging.debug(f"Get {component} returned {records} records") + + # handle pagination + if 'next_cursor' in response_json['response_metadata']: + logging.debug('Response is paginated getting the next page') + next_cursor = response_json['response_metadata']['next_cursor'] + next_page = get_data_from_dct( + component, query=QUERY+'&cursor={}'.format(next_cursor) + ) + response_json['items'].extend(next_page['items']) + return response_json From d4c63c1c05ff77415b289696b6bf4f48a3835aa7 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 6 Dec 2022 16:12:35 +0530 Subject: [PATCH 09/18] Readme update for catering to new code changes Also mentioned the configurable options in config.ini that can be used to configure the script --- README.md | 78 ++++++++++++------------------------------------------- 1 file changed, 16 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index e9b8ad1..6712d99 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This project will allow you to send data from [Delphix Data Control Tower Multic ## Getting Started -These instructions will provide the code you need to extract data from DCT Multicloud and send it to New Relic. +These instructions will provide the steps you need to extract data from DCT Multicloud and send it to New Relic. ### Prerequisites @@ -16,74 +16,24 @@ It's assumed that you have a New Relic valid account and one or many [Delphix En DCT Multicloud will extract data from the Delphix Engines and we will use [New Relic Telemetry SDK](https://docs.newrelic.com/docs/telemetry-data-platform/ingest-apis/telemetry-sdks-report-custom-telemetry-data/) to send that data to New Relic. For this project, we will use the [Python SDK](https://github.com/newrelic/newrelic-telemetry-sdk-python), however you can use any of the available SDKs in different languages. +We are using Python 3.8 for this project. Hence, prerequisite is to have Python 3.8 installed on your system. ### Installing - -To push the data from Delphix DCT Multicloud to New Relic, we use the script ```dlpx_dct_to_nr.py```. To use this script we have to do some steps first: * Generate the [keys to connect to DCT Multicloud](https://docs.delphix.com/dctmc/authentication) * Generate the [New Relic access key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) +* Note the URL of the DCT instance VM -Once we have these keys we need to replace them in the script: - -* In req_headers we replace the DCT Multicloud key -* In NEW_RELIC_INSERT_KEY we replace the New Relic access key - -This is the script: +To push the data from Delphix DCT Multicloud to New Relic, we will have to perform the below steps: -``` -import os -import requests -import json -import sys -import time -from newrelic_telemetry_sdk import Event, EventClient -from requests.packages.urllib3.exceptions import InsecureRequestWarning - -requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - -DLPX_TYPES= ["engines","sources","dsources","vdbs","environments"] -# -# Request Headers ... -# -req_headers = { - 'Authorization': 'apk 2.bnQDDx46Z4CDlIShLw2ZHElWLyKtsmZaBjbQPjui8LcQ3nELbkdEbQJSki6vmwLf' -} - -# -# Python session, also handles the cookies ... -# -session = requests.session() - -# -# Login ... -# -os.environ['NEW_RELIC_INSERT_KEY'] = "87a453b2efe4nd4df78b167e7ac457e076c7NRAL" -print ('') -for i in DLPX_TYPES: - - response = requests.get('https://localhost:443/v1/'+i, headers=req_headers, verify=False) - responsej = json.loads(response.text) - print("") - print("") - print("**********************************************************************************************************************************") - event_client = EventClient(os.environ["NEW_RELIC_INSERT_KEY"]) - NEWRELIC_TYPE="Delphix " + str(i) - print (NEWRELIC_TYPE) - for line in responsej['items']: - event = Event( - NEWRELIC_TYPE, line - ) - print (event) - response = event_client.send(event) - response.raise_for_status() - print("Event sent successfully!") - print("") - -print ('') -sys.exit(0) -``` +* We need to supply the above gathered information using 3 environment variables + * DCT_HOST_URL + * DCT_API_KEY + * NEW_RELIC_INSERT_KEY +* Clone this repository +* Run command `make env` (This will create the virtual environment) +* Run command `make run` (This will run the script and push the data) On execution, this script will extract data from all the registered Delphix Engines for the following metrics: @@ -93,8 +43,12 @@ On execution, this script will extract data from all the registered Delphix Engi * dSources - Data extraction date, dSource Creation Date, dSource Type, Version, Name, Status, Size, etc. * VDBs - Data extraction date, Database Type and Version, Creation Date, Group Name, Name, Parent ID, Size, Status, etc. -This script can be added to cron or any scheduler to run in any time interval. Once the data is available in New Relic, it can be used to be queried or to create dashboards. +More over we have `dct_nr_config.ini` file which can be used to configure +- Logging Level +- Interval (in seconds): This script keeps running and sleeps for `INTERVAL` seconds after sending the data once. +- Components we need from DCT APIs +Once the data is available in New Relic, it can be used to be queried or to create dashboards. ## Data and Dashboards From ef294b0493239fbacd9f19af8246ca5a190a6658 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Tue, 6 Dec 2022 16:22:17 +0530 Subject: [PATCH 10/18] version change to 0.1.0 --- src/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index 4e2c3f6..f3f964d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -2,4 +2,4 @@ # Copyright (c) 2022 by Delphix. All rights reserved. # -VERSION = "1.0.0" +VERSION = "0.1.0" From 188ca161046123ce3e0281248444de8c7061639a Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 7 Dec 2022 20:06:07 +0530 Subject: [PATCH 11/18] Changes for Adopting All python versions in MakeFile --- Makefile | 11 ++++++----- README.md | 24 +++++++++++++++++++++++- requirements.txt | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ee4fbe0..c680aca 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,16 @@ VENV := venv PYTHON := $(VENV)/bin/python PIP := $(VENV)/bin/pip DLPX_NR := $(ROOT_DIR)/dist/delphix-nr +DEFAULT_PYTHON3_ALIAS := python3 define show_version @export LC_ALL=en_AU.UTF-8; $(DLPX_NR) --version endef define check_python_exists - @if ! command -v python3.8 -V >/dev/null 2>&1; then \ - echo "Python 3.8 is NOT present on the system, Please install it"; \ + @if ! command -v $(DEFAULT_PYTHON3_ALIAS) -V >/dev/null 2>&1; then \ + echo "Python 3 is NOT present on the system, Please install it"; \ + echo "If it is installed, then change the "DEFAULT_PYTHON3_ALIAS" in Makefile";\ exit 1; \ fi endef @@ -41,7 +43,7 @@ tests: --create_virtual_env: --check_python @# Help: Creates a virtual environment -@echo 'Creating Virtual environment' - @python3.8 -m venv venv || echo 'Python env already exists' + @$(DEFAULT_PYTHON3_ALIAS) -m venv venv || echo 'Python env already exists' --install_dependencies: requirements.txt @# Help: Installs the dependencies from requirements.txt @@ -50,11 +52,10 @@ tests: @$(PIP) install -r requirements.txt env: --create_virtual_env --install_dependencies - @# Help: Creates a virtual environment with python3.8 if not already present and activates it + @# Help: Creates a virtual environment with python 3 if not already present clean_env: @# Help: Clean the virtual env that was created - -@$(VENV)/bin/pre-commit uninstall -@rm -rf venv clean_build: diff --git a/README.md b/README.md index 6712d99..35aedda 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,17 @@ It's assumed that you have a New Relic valid account and one or many [Delphix En DCT Multicloud will extract data from the Delphix Engines and we will use [New Relic Telemetry SDK](https://docs.newrelic.com/docs/telemetry-data-platform/ingest-apis/telemetry-sdks-report-custom-telemetry-data/) to send that data to New Relic. For this project, we will use the [Python SDK](https://github.com/newrelic/newrelic-telemetry-sdk-python), however you can use any of the available SDKs in different languages. -We are using Python 3.8 for this project. Hence, prerequisite is to have Python 3.8 installed on your system. +We are using Python 3.7+ for this project. Hence, prerequisite is to have Python 3.7+ installed on your system. + +
+

Supported Python Versions

+
+ +- MacOS - Python3.7 and Python3.8 +- Linux - Python3.7+ +- Windows - Python3.7+ + +
### Installing To use this script we have to do some steps first: @@ -32,9 +42,21 @@ To push the data from Delphix DCT Multicloud to New Relic, we will have to perfo * DCT_API_KEY * NEW_RELIC_INSERT_KEY * Clone this repository +* Go inside the project directory - `cd dct-newrelic-integration` + +For Mac and Linux: * Run command `make env` (This will create the virtual environment) * Run command `make run` (This will run the script and push the data) +For Windows: +* Check that python 3 is installed +* Create a virtual environment running `python -m venv venv` +* Activate the virtual environment by running `venv\Scripts\activate` +* Install the dependencies by running `pip install -r requirements.txt` +* Set Python path by - `set PYTHONPATH=.` +* Run the script using `python src\main.py` + + On execution, this script will extract data from all the registered Delphix Engines for the following metrics: * Engines - Data extraction date, CPU Count, Storage, Memory, Engine Type, Version, etc. diff --git a/requirements.txt b/requirements.txt index f12f83f..8015547 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ newrelic-telemetry-sdk==0.4.3 pyinstaller==5.6.2 requests==2.28.1 tenacity==8.1.0 -urllib3==1.26.12 +urllib3==1.26.13 \ No newline at end of file From 3cebaa00f99f08c23c82c04f4fc77a35745bad99 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 7 Dec 2022 20:22:50 +0530 Subject: [PATCH 12/18] Review comments --- .gitignore | 3 --- CONTRIBUTING.md | 2 +- Makefile | 1 + README.md | 2 +- setup.py | 2 +- src/main.py | 11 +++++------ 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index bddc6d9..4e0bbdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ venv/ -venv-38/ .idea/ -/venv3.9/ -/venv3.10/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0c8e2a..c0adafc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 by Delphix. All rights reserved. +# Copyright (c) 2021, 2022 by Delphix. All rights reserved. # ## Contributing diff --git a/Makefile b/Makefile index c680aca..e3c8b82 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # # Copyright (c) 2022 by Delphix. All rights reserved. # + .PHONY: --check_python --check_env_exists run tests --create_virtual_env --install_dependencies env clean_build clean_env clean build ROOT_DIR := $(shell pwd) diff --git a/README.md b/README.md index 35aedda..5b576bd 100644 --- a/README.md +++ b/README.md @@ -122,4 +122,4 @@ License See the License for the specific language governing permissions and limitations under the License. ``` -Copyright (c) 2014, 2016 by Delphix. All rights reserved. +Copyright (c) 2014, 2022 by Delphix. All rights reserved. diff --git a/setup.py b/setup.py index 512572e..60f6907 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2021,2022 by Delphix. All rights reserved. +# Copyright (c) 2022 by Delphix. All rights reserved. # from setuptools import find_packages diff --git a/src/main.py b/src/main.py index c2c1f9e..23e0b6e 100644 --- a/src/main.py +++ b/src/main.py @@ -11,11 +11,10 @@ import os.path import sys import time - +import urllib3 import newrelic_telemetry_sdk.client import requests import logging -import urllib3 import configparser import tenacity @@ -29,10 +28,10 @@ config = configparser.ConfigParser() if not os.path.exists(config_file): - raise Exception("Config file is required. " - "Please add dct_nr_config.ini in the current directory") + raise Exception("Config file is required." + " Please add dct_nr_config.ini in the current directory") -config.read_file(open("dct_nr_config.ini")) +config.read_file(open(config_file)) config_log_level = config['LOGGING']['LEVEL'] INTERVAL = int(config['INTERVAL']['seconds']) @@ -94,7 +93,7 @@ def send_event(event): before_sleep=tenacity.before_sleep_log(logging, logging.DEBUG), ) def get_data_from_dct(component, query=QUERY): - url = DCT_API_URL + component + query + url = f"{DCT_API_URL}{component}{query}" response = requests.get(url, headers=req_headers, verify=False) assert response.status_code == 200 response_json = response.json() From ecf5a885922610eb93367cb71bc67bc494675d73 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Thu, 8 Dec 2022 21:54:22 +0530 Subject: [PATCH 13/18] Addressing Review comments from Arun --- CONTRIBUTING.md | 19 +++++-------------- src/main.py | 26 +++++++++++++++++--------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0adafc..4c858f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,20 +4,11 @@ ## Contributing 1. Fork the project. - 2. Create a virtual environment with `Python 3.8` - - Pre Requisite is that you have `Python 3.8` already installed - - You can the run the below command to check that - - # python3.8 -V - output: 3.8.8 - - 3. Use Make command to create the environment. - `make env` - 4. Configure the values of API Keys and DCT URL in the `dct_nr_config.ini` file - 5. Run the script using command `make run` - 6. Make your bug fix or new feature. - 7. Add tests for your code. - 8. Send a pull request. + 2. Refer to [README.md](README.md) for the setup, pre-configurations and running the project. + 3. One you have run the script successfully using `make run` (Linux/MacOS) or `python src\main.py` (Windows) + 7. Make your bug fix or new feature. + 8. Add tests for your code. + 9. Send a pull request. Contributions must be signed as `User Name `. Make sure to [set up Git with user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). Bug fixes should branch from the current stable branch. New features should be based on the release branch. diff --git a/src/main.py b/src/main.py index 23e0b6e..27d3bf5 100644 --- a/src/main.py +++ b/src/main.py @@ -11,6 +11,8 @@ import os.path import sys import time +import traceback + import urllib3 import newrelic_telemetry_sdk.client import requests @@ -95,6 +97,7 @@ def send_event(event): def get_data_from_dct(component, query=QUERY): url = f"{DCT_API_URL}{component}{query}" response = requests.get(url, headers=req_headers, verify=False) + logging.debug("DCT API - % responded with %", url, response.status_code) assert response.status_code == 200 response_json = response.json() records = response_json['response_metadata']['total'] @@ -119,15 +122,20 @@ def push_data(): datetime.datetime.now()) logging.info('*' * 70) for i in DLPX_TYPES: - response_json = get_data_from_dct(i) - - new_relic_type = "Delphix " + str(i).split('/')[-1] - logging.info("Sending Data for %s \n", new_relic_type) - for line in response_json['items']: - event = Event( - new_relic_type, line - ) - send_event(event) + try: + logging.debug("Getting Data from DCT for %s ", i) + response_json = get_data_from_dct(i) + + new_relic_type = "Delphix " + str(i).split('/')[-1] + logging.info("Sending Data for %s \n", new_relic_type) + for line in response_json['items']: + event = Event(new_relic_type, line) + send_event(event) + except Exception as e: + logging.error("Exception occurred while collecting or" + " sending data for component - %s", i) + logging.error(e) + logging.error(traceback.format_exc()) logging.info(f"Sleeping for %s seconds before pushing again", INTERVAL) logging.info('-' * 70) From 5e3b7eb93fa1fcd31ca359117cf5f67fa5aaed16 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Thu, 8 Dec 2022 21:56:31 +0530 Subject: [PATCH 14/18] Addressing Review comments from Arun --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 27d3bf5..6ac108c 100644 --- a/src/main.py +++ b/src/main.py @@ -97,7 +97,7 @@ def send_event(event): def get_data_from_dct(component, query=QUERY): url = f"{DCT_API_URL}{component}{query}" response = requests.get(url, headers=req_headers, verify=False) - logging.debug("DCT API - % responded with %", url, response.status_code) + logging.debug("DCT API - %s responded with %s", url, response.status_code) assert response.status_code == 200 response_json = response.json() records = response_json['response_metadata']['total'] From 5ec5daea8e6fbd891ab23946555f9bf81e24b763 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Fri, 9 Dec 2022 13:35:27 +0530 Subject: [PATCH 15/18] Addressing Review comments from Nick --- README.md | 6 ++---- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 14343f0..b1f3ae6 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,9 @@ These instructions will provide the information you need to extract data from DC * New Relic Account: [Sign Up](https://newrelic.com/signup) * Delphix Data Control Tower (DCT) with one or more engines: [Data Control Tower Docs](https://delphix.document360.io/dct/docs) -* Python 3.8+: [Python Install](https://www.python.org/downloads) +* Python 3.7+: [Python Install](https://www.python.org/downloads) * This [GitHub repository](https://github.com/delphix/dct-newrelic-integration) -We are using Python 3.7+ for this project. Hence, prerequisite is to have Python 3.7+ installed on your system. -

Supported Python Versions


@@ -33,7 +31,7 @@ We are using Python 3.7+ for this project. Hence, prerequisite is to have Python ### Installing To use this script we have to do some steps first: -* Generate the [keys to connect to DCT](https://docs.delphix.com/dctmc/authentication) +* Generate the [key to connect to DCT](https://docs.delphix.com/dctmc/authentication) * Generate the [New Relic access key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) * Note the URL of the DCT instance VM diff --git a/setup.py b/setup.py index 60f6907..de15820 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from src.main import VERSION # Get the long description from the README file -long_description = "This is an executable for Delphix New Relic Integration" +long_description = "This is an executable for the Delphix Integration for New Relic" setup( version=VERSION, @@ -34,7 +34,7 @@ author="Delphix Engineering", keywords="new-relic, delphix, dct", # noqa license="Apache 2", - description="Delphix New Relic Integration", + description="Delphix Integration for New Relic", dependency_links=[], name="delphix-nr", long_description_content_type="text/markdown", From ab9051f903142abecba4df710f35b5b8beff2d26 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 14 Dec 2022 12:13:09 +0530 Subject: [PATCH 16/18] Update CONTRIBUTING.md and SUPPORT.md --- CONTRIBUTING.md | 28 ++++++++++++++++++---------- README.md | 4 ++-- SUPPORT.md | 10 ++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c858f8..07c8356 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,18 +2,26 @@ # Copyright (c) 2021, 2022 by Delphix. All rights reserved. # -## Contributing - 1. Fork the project. - 2. Refer to [README.md](README.md) for the setup, pre-configurations and running the project. - 3. One you have run the script successfully using `make run` (Linux/MacOS) or `python src\main.py` (Windows) - 7. Make your bug fix or new feature. - 8. Add tests for your code. - 9. Send a pull request. +Not accepting any external contributions as of now. -Contributions must be signed as `User Name `. Make sure to [set up Git with user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). Bug fixes should branch from the current stable branch. New features should be based on the release branch. +
+--- Hidden Block ---- + + ## Contributing + 1. Fork the project. + 2. Refer to [README.md](README.md) for the setup, pre-configurations and running the project. + 3. Once you have run the script successfully using `make run` (Linux/MacOS) or `python src\main.py` (Windows) + 7. Make your bug fix or new feature. + 8. Add tests for your code. + 9. Send a pull request. + + Contributions must be signed as `User Name `. Make sure to [set up Git with user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). Bug fixes should branch from the current stable branch. New features should be based on the release branch. + + ## Contributor Agreement + All contributors are required to sign the Delphix Contributor agreement prior to contributing code to an open source repository. This process is handled automatically by [cla-assistant](https://cla-assistant.io/). Simply open a pull request and a bot will automatically check to see if you have signed the latest agreement. If not, you will be prompted to do so as part of the pull request process. -## Contributor Agreement -All contributors are required to sign the Delphix Contributor agreement prior to contributing code to an open source repository. This process is handled automatically by [cla-assistant](https://cla-assistant.io/). Simply open a pull request and a bot will automatically check to see if you have signed the latest agreement. If not, you will be prompted to do so as part of the pull request process. +------------------------ +
## Code of Conduct This project operates under the Delphix Code of Conduct. By participating in this project you agree to abide by its terms. diff --git a/README.md b/README.md index b1f3ae6..14f5b5f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ These instructions will provide the information you need to extract data from DC * This [GitHub repository](https://github.com/delphix/dct-newrelic-integration)
-

Supported Python Versions

+

Supported Python Versions and OS


- MacOS - Python3.7 and Python3.8 @@ -63,7 +63,7 @@ Note: You may modify the Python script directly, but it is best practice to spec
In production, it is common to use a scheduler, such as a systemd, nohup, or wininit.exe, to ensure the script continually runs. For example, the following nohup command will run the script every N seconds based on the Interval provided in the `dct_nr_config.ini` file: -```nohup python src/main.py &``` +```nohup make run &``` On each execution, this script will extract the following metrics from all registered Delphix engines: diff --git a/SUPPORT.md b/SUPPORT.md index 60e840d..ed92594 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,2 +1,12 @@ ## Support This software is provided as-is, without warranty of any kind or commercial support through Delphix. See the associated license for additional details. Questions, issues, feature requests, and contributions should be directed to the community as outlined in the [Delphix Community Guidelines](https://delphix.github.io/community-guidelines.html). + +
+

Supported Python Versions and OS

+
+ +- MacOS - Python3.7 and Python3.8 +- Linux - Python3.7+ +- Windows - Python3.7+ + +
\ No newline at end of file From 0b7ddcd9213a76c6e8aaf1f981cbf16a57fc1d27 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 14 Dec 2022 13:09:02 +0530 Subject: [PATCH 17/18] Update CONTRIBUTING.md and SUPPORT.md --- CONTRIBUTING.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07c8356..2f5665f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ # Copyright (c) 2021, 2022 by Delphix. All rights reserved. # -Not accepting any external contributions as of now. +This project is currently not accepting external contributions.
--- Hidden Block ---- diff --git a/README.md b/README.md index 14f5b5f..bd44a07 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ SELECT MAX(data_storage_capacity)-MIN(data_storage_used) FROM `Delphix engines` ## Contributing -Please read [CONTRIBUTING.md](https://github.com/delphix/.github/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. +This project is currently not accepting external contributions. ## Versioning From 696cc4a27742eba76856795572e4ad3fd9bdc072 Mon Sep 17 00:00:00 2001 From: "rohit.shende" Date: Wed, 14 Dec 2022 13:57:16 +0530 Subject: [PATCH 18/18] Removing copyright from README.md following MySQL and Terraform --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index bd44a07..59b4137 100644 --- a/README.md +++ b/README.md @@ -135,5 +135,3 @@ License See the License for the specific language governing permissions and limitations under the License. ``` - -Copyright (c) 2014, 2022 by Delphix. All rights reserved.