API Reference
This documentation describes the functionality that is available for configuration authors.
Documentation describing the functionality and schema of configuration (workflow, bootstrap etc.) is referred to as the model and is available below.
Documentation describing the functionality and schema of the testing harness is available below.
opscotch configuration model
The opscotch model is relatively straight forward, and uses repeated patterns - once you grasp these you should be able to understand the entire structure.
Here is the outline of the entire structure of the two configurations: the bootstrap and the workflow. Note that not every field is required, so be sure to check the detailed descriptions.
The bootstrap schema overview
[
{
"enabled" : true,
"agentPrivateKey": "",
"deploymentId": "",
"remoteConfiguration": "",
"remoteConfigurationAuth": "",
"remoteConfigurationTimeout" : 0,
"frequency": 0,
"reloadTimeout" : 0,
"errorHandling": {
"enableLocalLogging": true,
"metrics": {
"enabled": true,
"routingToken": "",
"outputUrl": "",
"outputAuthorization": ""
},
"logs": {
"enabled": true,
"routingToken": "",
"outputUrl": "",
"outputAuthorization": ""
},
"redactionPatterns": [
""
]
},
"workflow" : {
"metricOutput": {
"enabled": true,
"routingToken": "",
"outputUrl": "",
"outputAuthorization": ""
},
"errorHandling": {
"enableLocalLogging": true,
"metrics": {
"enabled": true,
"routingToken": "",
"outputUrl": "",
"outputAuthorization": ""
},
"logs": {
"enabled": true,
"routingToken": "",
"outputUrl": "",
"outputAuthorization": ""
}
}
},
"allowExternalHostAccess": [
{
"authenticationHost" : true,
"id" : "",
"host": "",
"headers": {
"": ""
},
"allowList" : [
{
"method" : "",
"uriPattern" : ""
}
],
"data" : {}
}
],
"allowFileAccess": [
{
"id" : "",
"directoryOrFile" : "",
"patterns" : [""],
"LIST" : true,
"READ" : true,
"WRITE" : true,
"DELETE" : true
}
],
"allowHttpServerAccess": [
{
"id" : "",
"port" : 0,
"serveFromPackagedAsset" : {
"packagedAssetFileId": ""
}
}
],
"persistenceRoot" : "",
"data": {}
}
]
The workflow schema overview
{
"workflows": [
{
"enabled": true,
"name": "",
"steps": [
{
"enabled": true,
"debug": true,
"type": "",
"stepId": "",
"trigger" : {
"fileWatcher": {
"bootstrapFileId": "",
"eventSplitter": "",
"patterns": [ "" ],
"splitAtEnd": false
},
"http": {
"method": "",
"path": "",
"server" : ""
},
"timer" : {
"delay" : 0,
"period" : 0
},
"runOnce" : true
},
"authenticationProcessor": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"splitGenerator": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"urlGenerator": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"payloadGenerator": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"itemResultProcessor": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"resultsProcessor": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"httpStatusHandling": {
"" : {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
}
},
"httpConnectFailedProcessor": {
"script": "",
"resource": "",
"processors" : [
{
"script": "",
"resource": ""
"data": {}
}
],
"data": {}
},
"httpTimeout" : 0,
"singleThreaded" : "",
"persistenceFile" : "",
"data": {}
}
],
"data" : {},
}
]
}
Bootstrap JSON Schemas
JSON Schema in the Bootstrap Package:
Bootstrap
A configuration that is loaded into the agent at startup and determines how the agent loads the main configuration is loaded.
Please note that the bootstap file that is authored is an ARRAY of these objects ie:
[
{
"agentPrivateKey": ...
"deploymentId": ...
}
]
It will be provided to the agent as an argument, either via a base64 encoded json text or a path to a json file
JSON Properties
The following properties are available to set on the JSON schema.
agentPrivateKey
Type: String
Required The private key for the agent to decrypt the remote configuration.
This should be a base64 encoded private key in pkcs8 format
This is how to create an appropriate key
1. Create key pair
openssl genrsa -out keypair.pem 2048
2. Extract public part
openssl rsa -in keypair.pem -pubout -out public.key
3. Extract private part
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out private.key
4. Base64 the contents of this file
cat private.key | base64
{
"agentPrivateKey": "LS0tLS1CRUdJTiBQUklWQV...."
}
This property is required
allowExternalHostAccess
Type: List of Host
A list of Host objects that describes access to external http(s) services that can be called from the workflow configuration.
{
"allowExternalHostAccess": [
{
"id" : "myHost",
"host": "https://www.example.com",
"headers": {
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, *\/*"
},
"allowList" : [
{ "method" : "GET", "uriPattern" : "/this/is/allowed.*"},
{ "method" : "POST", "uriPattern" : "/this/.*\/allowed"}
],
"data" : {
}
}
}
]
This property is optional
allowFileAccess
Type: List of FilePermitter
A list of File Permitters that describe access to files and directories.
When a directory is specified the permissions apply to all files in that directory.
Available permissions are:
- LIST
- READ
- WRITE
{
"allowFileAccess": [
{
"id" : "myTxtFiles",
"directoryOrFile" : "/path/to/a/directory",
"pattern" : ".*\\.txt",
"READ" : true
}
]
}
This property is optional
allowHttpServerAccess
Type: List of HttpServerPermitter
A list of Http Server Permitters that describe access https servers running in the agent.
This is a configuration for starting HTTP servers in the agent.
{
"allowHttpServerAccess": [
{
"id" : "myHttpServer",
"port" : 1234
}
]
}
This property is optional
data
Type: Object
A JSON Object for adding properties.
These properties will be merged with the WorkflowConfiguration.data configuration field and be available to all child elements in the main configuration tree.
{
"data": {
"somedata" : {
"abc: 123
},
"someotherdata" : [ 1, 2, 3]
}
}
This property is optional
deploymentId
Type: String
Required A Service Provider defined value that must be unique per deployed agent configuration.
This property is used by Service Provider downstream processor to enrich the transmitted data.
{
"deploymentId": "a7d2f8"
}
This property is required
enabled
Type: Boolean
Disable is bootstrap by setting enabled : false
Defaults to true
{
"enabled": false
}
This property is optional
errorHandling
Type: ErrorHandling
Determines the behavior of error handling while loading the main configuration
{
"errorHandling": {
...
}
}
This property is optional
frequency
Type: Integer
When using a URL Bootstrap.remoteConfiguration, setting this property will set the polling period in milliseconds
Defaults to 60000 (60 seconds)
{
"remoteConfiguration": "http://www.example.com",
"remoteConfigurationAuth" : "xodsjfujrhdjfk",
"frequency" : 60000
}
This property is optional
hosts
DEPRICATED: use allowExternalHostAccess Type: Object of Host
A set of named Host objects. This allows the bootstrap to define http(s) host that can be called from the main configuration.
{
"hosts": {
"mynamedhost": {
"host": "https://www.example.com",
"stepId": "example.com",
"headers": {
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, *\/*"
},
"allowlist" : [
["GET", "/this/is/allowed.*"],
["POST", "/this/.*\/allowed"]
],
"data" : {
}
}
}
}
This property is optional
persistenceRoot
Type: String
Defines the filesystem storage root for persistence
{
"persistenceRoot": "/storage"
}
This property is optional
reloadTimeout
Type: Integer
Defines the maximum time in milliseconds to wait for a workflow to terminate running flows before loading a new version
Defaults to 10000 (10 seconds)
{
"reloadTimeout": 1000
}
This property is optional
remoteConfiguration
Type: String
Required A URL or file path to the main configuration.
The main configuration does not exist, the agent will wait until it becomes available. When referencing a file, its important to remember that the path is relative to the opscotch working directory, NOT the bootstrap file
{
"remoteConfiguration": "http://www.example.com",
"remoteConfigurationAuth" : "xodsjfujrhdjfk",
"frequency" : 60000
}
This property is required
remoteConfigurationAuth
Type: String
When using a URL remoteConfiguration, setting this property will set the "Authorization" header
{
"remoteConfiguration": "http://www.example.com",
"remoteConfigurationAuth" : "xodsjfujrhdjfk",
"frequency" : 60000
}
This property is optional
remoteConfigurationTimeout
Type: Integer
When using a URL remoteConfiguration, setting this property will set the http timeout period in milliseconds
The remoteConfigurationTimeout must be less than the frequency
Defaults to 1000 (1 second)
{
"remoteConfiguration": "http://www.example.com",
"remoteConfigurationAuth" : "xodsjfujrhdjfk",
"frequency" : 60000,
"remoteConfigurationTimeout" : 1000
}
This property is optional
workflow
Type: WorkflowOutputs
Determines metric and log outputs for the workflows
{
"workflow": {
...
}
}
This property is optional
ErrorHandling
A configuration defining if and how to send error metrics or log to a remote system
JSON Properties
The following properties are available to set on the JSON schema.
enableLocalLogging
Type: Boolean
Enable or disables logging of errors and information to the agent standard out
Defaults to true
{
"enableLocalLogging": true
}
This property is optional
logs
Type: Output
Defines how error logs are sent to a remote system.
Error logs are brief messages from a fault in the agent and are sent to a remote system for attention.
Error log configuration only apply to the process configuration they are defined for. For example the Bootstrap.errorHandling defines error handling while loading configurations, and the WorkflowConfiguration.errorHandling defines error handling during the execution of configuration steps.
{
"logs": {
...
}
}
This property is optional
metrics
Type: Output
Defines how error metrics are sent to a remote system.
Error metrics represent a fault in the agent and are sent to a remote system for attention.
Error metric configuration only apply to the process configuration they are defined for. For example the Bootstrap.errorHandling defines error handling while loading configurations, and the WorkflowConfiguration.errorHandling defines error handling during the execution of configuration steps.
{
"metrics": {
...
}
}
This property is optional
redactionPatterns
Type: Array of String
Defines regex patterns to apply redaction to log statements
Log statements from will have these redaction patterns applied before logging.
{
"redactionPatterns": [
"[0-9]+"
]
}
This property is optional
FilePermitter
Describes controlled access to files and directories.
Regular Expressions can be used to further restrict access to specific files.
JSON Properties
The following properties are available to set on the JSON schema.
DELETE
Type: Boolean
When true files will be deletable.
Defaults to false
{
"DELETE": true
}
This property is optional
LIST
Type: Boolean
When true files will be listable.
Defaults to false
{
"LIST": true
}
This property is optional
READ
Type: Boolean
When true files will be readable.
Defaults to false
{
"READ": true
}
This property is optional
WRITE
Type: Boolean
When true files will be writable.
Defaults to false
{
"WRITE": true
}
This property is optional
directoryOrFile
Type: String
A path to a directory or file.
The directory or file does not need to exist. If a directory is specified it must end in a / (or the OS file separator)
Directory example:
{
"directoryOrFile": "/path/to/directory/"
}
File example:
{
"directoryOrFile": "/path/to/directory/or/file"
}
This property is required
id
Type: String
An id that must be unique to this bootstrap.
Use this id in the workflow step file trigger.
{
"id": "myTextFiles"
}
This property is required
patterns
Type: List of Strings
A list of (Java) Regular Expressions that can be used to further restrict access to files in the directory
{
"patterns": [
".*\\.txt$",
".*\\.log$"
]
}
This property is optional
Host
A HTTP(S) host that the agent is expected to communicate with.
This only applies to customer specific hosts, not to Service Provider hosts.
Hosts are defined in Bootstrap.data and WorkflowConfiguration.data
JSON Properties
The following properties are available to set on the JSON schema.
allowList
Type: List of HostAllow
A list of allowed paths that may be called on this host.
A list of regex that will be matched to URL path. Matching results will be allowed, non-matching results will be blocked and logged.
{
"allowList": [
{ "method" : "GET", "uriPattern" : "/this/is/allowed"},
{ "method" : "POST", "uriPattern" : "/this/.*\/allowed"}
]
}
This property is optional
authenticationHost
Type: Boolean
When set to true the host can only be used by an authentication context,
when set to false (default) the host can only be used by a non-authentication context.
{
"authenticationHost": true
}
Defaults to false
This property is optional
data
Type: Object
A JSON Object with Additional properties that will accessible during authentication steps.
You can use environment variables in the form of ${NAME} anywhere in the data structure:
the environment variable will be substituted prior to parsing.
Strings in the data structure (after environment variable substitution) can be encrypted using the opscotch packager. Values will be decrypted at access time.
Encryption is done via the packaging tool and requires the agent public key.
{
"data": {
"somedata" : {
"abc: 123
},
"someotherdata" : [ 1, 2, 3],
"someencryptedstring" : {
"abc" : "some encrypted value"
}
}
}
This property is optional
headers
Type: Object of Strings
A object of HTTP headers to be sent with every call.
{
"headers": {
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, *\/*"
}
}
This property is optional
host
Type: String
Required A URL that is used as the base for constructing URLs to call.
{
"host": "https://www.example.com:8080"
}
This property is required
id
Type: String
Required A unique string that identifies this host in other configurations.
{
"id": "myHost"
}
This property is required
HostAllow
Defines allowed http access patterns
JSON Properties
The following properties are available to set on the JSON schema.
method
Type: String
HTTP Method to match on. One of:
- GET
- HEAD
- POST
- PUT
- DELETE
- OPTIONS
- PATCH
{
"method": "GET"
}
This property is required
uriPattern
Type: String
Regex pattern to match on the URI.
{
"uriPattern": ".*"
}
This property is required
HttpServerPermitter
Creates an HTTP server bound to the specified port.
Steps for this bootstrap using a http trigger can bind to this http server.
A special feature is being able to serve static content from a zip file - see serveFromPackagedAsset
JSON Properties
The following properties are available to set on the JSON schema.
id
Type: String
Required A unique string that identifies this http server in other configurations.
{
"id": "myAPI"
}
This property is required
port
Type: String
Required A port on the host that this http server will bind to. Normal port binding rules apply.
{
"port": 1234
}
This property is required
serveFromPackagedAsset
Type: ServePackagedAsset
Describes how to serve content from a zip file.
{
"serveFromPackagedAsset": {
...
}
}
This property is optional
OldHost
DEPRICATED This is the old host structure and has been replaced with the new host structure. See allowExternalHostAccess
A HTTP(S) host that the agent is expected to communicate with.
This only applies to customer specific hosts, not to Service Provider hosts.
Hosts are defined in Bootstrap.data and WorkflowConfiguration.data
JSON Properties
The following properties are available to set on the JSON schema.
allowlist
Type: List of HostAllow
A list of allowed paths that may be called on this host.
A list of regex that will be matched to URL path. Matching results will be allowed, non-matching results will be blocked and logged.
{
"allowlist": [
["GET","/this/is/allowed"],
["POST","/this/.*\/allowed"]
]
}
This property is optional
authenticationHost
Type: Boolean
When set to true the host can only be used by an authentication context,
when set to false (default) the host can only be used by a non-authentication context.
{
"authenticationHost": true
}
Defaults to false
This property is optional
data
Type: Object
A JSON Object with Additional properties that will accessible during authentication steps.
You can use environment variables in the form of ${NAME} anywhere in the data structure:
the environment variable will be substituted prior to parsing.
Strings in the data structure (after environment variable substitution) can be encrypted using the opscotch packager. Values will be decrypted at access time.
Encryption is done via the packaging tool and requires the agent public key.
{
"data": {
"somedata" : {
"abc: 123
},
"someotherdata" : [ 1, 2, 3],
"someencryptedstring" : {
"abc" : "some encrypted value"
}
}
}
This property is optional
headers
Type: Object of Strings
A object of HTTP headers to be sent with every call.
{
"headers": {
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, *\/*"
}
}
This property is optional
host
Type: String
Required A URL that is used as the base for constructing URLs to call.
{
"host": "https://www.example.com:8080"
}
This property is required
Output
Configuration for how to send data to a remote system.
JSON Properties
The following properties are available to set on the JSON schema.
enabled
Type: Boolean
Enables or disables the sending of data.
Defaults to false
{
"enabled": true
}
This property is optional
outputAuthorization
Type: String
Set the "Authorization" header.
{
"outputAuthorization" : "xodsjfujrhdjfk"
}
This property is optional
outputUrl
Type: String
Required The URL that data is transmitted to.
{
"outputUrl": "http://www.example.com"
}
This property is required
persistenceRoot
Type: String
If set, defines the location to store output queue files
{
"persistenceRoot" : "/tmp/output-queues"
}
routingToken
Type: String
Required A Service Provider defined value that must be unique per deployed agent.
This property is used by Service Provider downstream processor to direct and enrich the transmitted data.
{
"routingToken": "dogurj"
}
This property is required
ServePackagedAsset
Defines how to serve static files from a packaged asset (zip file)
JSON Properties
The following properties are available to set on the JSON schema.
packagedAssetFileId
Type: String
Identifies a FilePermitter in the bootstrap to serve from.
THe FilePermitter should be a path to a zip file.
{
"packagedAssetFileId": "myZipFile"
}
This property is required
WorkflowConfiguration
The configuration that describes the main activities of the agent
JSON Properties
The following properties are available to set on the JSON schema.
data
Type: Object
A JSON Object for adding properties.
These properties will be merged with the Bootstrap.data configuration field and be available to all child elements.
{
"data": {
"somedata" : {
"abc: 123
},
"someotherdata" : [ 1, 2, 3]
}
}
This property is optional
workflows
Type: Array of Workflow
Required A list of Workflow describing the agent tasks
{
"workflows" [
...
]
}
This property is required
WorkflowOutputs
Determines the behaviour of error handling and metrics for the workflow
JSON Properties
The following properties are available to set on the JSON schema.
errorHandling
Type: ErrorHandling
Determines the behavior of error handling while running the main configuration
{
"errorHandling": {
...
}
}
This property is optional
metricOutput
Type: Output
Metrics represent a data point that is interesting, generated by the agent and are sent to a remote system for analysis.
{
"metricOutput": {
...
}
}
This property is optional
Workflow JSON Schemas
JSON Schema in the Workflow Package:
Scripting context objects in the Workflow Package:
FileWatchingTrigger
Defines a trigger that fires when new lines are added to a file.
Each event (split by the lineSplit property) will be sent to the step processor. A sample event:
{
"log": {
"file": {
"path": "/path/to/file.txt"
},
"offset": 4130
},
"message": "this is a line from a file",
"input": {
"type": "log"
},
"host": {
"name": "hostname",
"ip": "[fe80:0:0:0:a6d7:feea:f601:902%wlp1s0, 192.168.0.27]"
},
"agent": {
"type": "opscotch",
"version": "3.0.0"
},
"ecs": {
"version": "1.12"
}
}