Instrumenting External Provided Python Extension
- Replace/Add Support files to the uniquely named folder
- In the support files, make sure the imports have no errors (changing to relative imports)
- Replace/Add the main file into the extensions folder
- Comment out any calls to class/function
- Make sure imports are relative
- Add the imports if not already there
From ruxit.api.base_plugin import RemoteBasePlugin import pytz from croniter import croniter from datetime import datetime |
- Add “(RemoteBasePlugin)” after the class name
- Change the “__init__” function name to “initialize”
- Add “**kwargs” parameter to the functions (initialize and query functions)
- In the initialize function add:
self.cron = self.config[“cron”] self.tz = pytz.timezone(‘America/New_York’)
self.theDynatrace_api_token = self.config[“api_token”] self.theSSPasswordFromExtension = self.config[“secret_server_api_password”] |
- For Satish’s code -> make sure the logger only has the file name (relative)
- In the query function add:
if croniter.is_valid(self.cron): cronNow = self.tz.localize(datetime.now()).replace(second=0, microsecond=0) run = croniter.match(self.cron, cronNow) if run: *your code* else: raise ValueError(“Cron Input is not valid”) |
- Add a plugin.json file
- “name”: “custom.remote.python.<your python filename>”
- “version” : “0.1” for dev and “1.0” for production, each time you deploy you must add .1 manually (1.0 -> 1.1)
- “package” : “<your python filename>”
- “className” : think just start with capital letter, use camel case, and must be unique
- “displayName”: “IAM | <whatever Satish gave you>”
- Send build file to Enterprise Monitoring for deployment