In this example you will create a dynatrace_entity
blueprint that ingests monitored entities from your Dynatrace account. You will then add some python script to make API calls to Dynatrace REST API and fetch data for your account.
Create the dynatrace entity blueprint in Port using this schema:
{
"identifier": "dynatrace_entity",
"description": "Ingest Dynatrace entities into your software catalog",
"title": "Dynatrace Entity",
"icon": "Dynatrace",
"schema": {
"properties": {
"type": {
"title": "Type",
"description": "Entity Type",
"type": "string"
},
"tags": {
"title": "Tags",
"type": "array"
},
"last_seen": {
"title": "Last Seen",
"type": "string",
"format": "date-time"
},
"first_seen": {
"title": "First Seen",
"type": "string",
"format": "date-time"
},
"to_relationships": {
"title": "To Relationships",
"type": "object",
"description": "A list of relationships where the entity occupies the TO position"
},
"properties": {
"title": "Properties",
"description": "A list of additional properties of the entity",
"type": "object"
},
"from_relationships": {
"title": "From Relationships",
"description": "A list of relationships where the entity occupies the FROM position",
"type": "object"
},
"management_zones": {
"title": "Management Zones",
"description": "A set of management zones to which the entity belongs",
"type": "array"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}
To ingest data from your Dynatrace account to Port, run the following commands:
export PORT_CLIENT_ID=<ENTER CLIENT ID>
export PORT_CLIENT_SECRET=<ENTER CLIENT SECRET>
export DYNATRACE_API_KEY=<ENTER DYNATRACE API KEY>
export DYNATRACE_HOST_URL=<ENTER DYNATRACE API URL>
export DYNATRACE_ENTITY_SELECTORS=<ENTER DYNATRACE ENTITY SELECTORS>
git clone https://github.com/port-labs/example-dynatrace-entities.git
cd example-dynatrace-entities
pip install -r ./requirements.txt
python app.py
The list of variables required to run this script are:
PORT_CLIENT_ID
- Port client IDPORT_CLIENT_SECRET
- Port client secretDYNATRACE_API_KEY
- Dynatrace access tokenDYNATRACE_HOST_URL
- Dynatrace host such ashttps://my-environment-id.live.dynatrace.com
DYNATRACE_ENTITY_SELECTORS
- An optional comma separated list of Dynatrace entity types such asHOST,APPLICATION,DATASTORE
. If not specified, the default will beKUBERNETES_SERVICE,DATASTORE,APPLICATION,HOST,SERVICE
. Check here for a complete list of valid entity types.
Follow the official documentation on how to generate API key