Get started with Opsgenie as a user
Learn how to configure your profile, get notifications from Opsgenie and view on-call schedules.
Prerequisites
For setting configuration file properties such as location and path:
First, you should set some environment variables for the locate configuration file.
There are two options here, you can get the configuration file from a local drive or by using git.
For reading configuration files from a local drive:
Set OEC_CONF_SOURCE_TYPE and OEC_CONF_LOCAL_FILEPATH variables.
For Redhat 6 / Centos 6 edit the /etc/init.d/oec file add these 2 export commands just before the "start()" function:
/etc/init.d/oec
1
2
3
4
export OEC_CONF_SOURCE_TYPE="local"
export OEC_CONF_LOCAL_FILEPATH="/home/opsgenie/oec/config.json"
start().......
For Redhat 7 / Centos 7 and Debian / Ubuntu edit the /etc/systemd/system/oec.service file, inside the [Service] key add the following "Environment" properties just before the start of the [install] key:
/etc/systemd/system/oec.service
1
2
3
4
5
6
7
8
...
[Service]
...
...
Environment="OEC_CONF_SOURCE_TYPE=local"
Environment="OEC_CONF_LOCAL_FILEPATH=~/oec/config.json"
...
[Install]
For Windows Sytems edit the oecService<32 | 64>.json file provided in the zip file you downloaded when you followed the instructions on our "Installation" page. The JSON contains a key called "Env" it takes an array as its value, lists the "OEC_CONF_LOCAL_FILEPATH" and "OEC_CONF_SOURCE_TYPE" with their values within the "Env" key's array.
JSON
1
2
3
4
5
6
7
8
...
...
"Env": [
"OEC_CONF_LOCAL_FILEPATH=C:\\opsgenie\\oec-win64\\config.json",
"OEC_CONF_SOURCE_TYPE=local"
],
...
...
From reading configuration files from a git repository:
Set OEC_CONF_GIT_URL, OEC_CONF_GIT_FILEPATH, OEC_CONF_GIT_PRIVATE_KEY_FILEPATH, and OEC_CONF_GIT_PASSPHRASE variables.
If you are using a public repository, you should use an https format of a git url and you do not need to set private key and passphrase.
You can set OEC_API_KEY variable (optional), if this property is set in the environment its value will be used as apiKey otherwise apiKey from configuration file (mentioned below) will be used.
Key | Value Properties | Example |
---|---|---|
OEC_CONF_SOURCE_TYPE | git → For getting from git | OEC_CONF_SOURCE_TYPE=git |
OEC_CONF_LOCAL_FILEPATH | filepath with extension (.yaml, .yml or .json) | OEC_CONF_LOCAL_FILEPATH=/home/Opsgenie/OECConfig.yaml |
OEC_CONF_GIT_URL | HTTPS or SSH url of the git repository | OEC_CONF_GIT_URL=git@bitbucket.com:metehan/test-private-conf-cem.git |
OEC_CONF_GIT_FILEPATH | filepath in the git repository folder (.yaml, .yml or .json) | OEC_CONF_GIT_FILEPATH=~/oec/config.json |
OEC_CONF_GIT_PRIVATE_KEY_FILEPATH | git ssh key location in local drive | OEC_CONF_GIT_PRIVATE_KEY_FILEPATH=~/.ssh/id_rsa |
OEC_CONF_GIT_PASSPHRASE | ssh passphrase | OEC_CONF_GIT_PASSPHRASE=1234 |
OEC_LOG_FORMAT_TYPE | text → logrus text type logs | OEC_LOG_FORMAT_TYPE=text |
OEC_API_KEY | API key from Opsgenie’s OEC Integration page, if this property is set it will override apiKey provided in configuration file. | OEC_API_KEY=4XXXXXX7-XXXX-XXXX-XXXX-9XXXXXXXXXX4 |
‘~’ character can be used as home directory for running the program as a user in customer’s server.
Prometheus default metrics can be grabbed from
http://localhost:<port-number>/metrics
To run multiple OEC in the same environment, -oec-metrics flag should be set as distinct port number values.
-oec-metrics <port-number>
OEC log file is located:
On Windows: var/log/opsgenie/oec<pid>.log
On Linux: /var/log/opsgenie/oec<pid>.log
At the end of the file name of the log, there is program identifier (pid) to identify which process is running.
OEC supports json and yaml file extension with fields. Configuration filepath should be set on
OEC_CONF_LOCAL_FILEPATH
or
OEC_CONF_GIT_FILEPATH
according to local or git choice.
Field | Type | Mandatory | Description |
---|---|---|---|
apiKey | string | true | The API key which is copied from Opsgenie’s OEC Integration page |
baseUrl | string | false | The API url of the Opsgenie mirror |
logLevel | string | false | Log level of the OEC |
globalArgs | list of string | false | Execute arguments that applies to all actions |
globalFlags | map of string key-value | false | Execute flags that applies to all actions |
globalEnv | list of string | false | Each element indicates one environment variable name and value separated with ‘=’ character. Applies to all actions. (e.g., “ENV1=value”) |
actionMappings | map of string key and mappedAction value | true | Map of the alert action mappings |
actionMappings → mappedAction | map | true | Each mappedAction represents an action and includes an action properties sourceType, filepath, gitOptions and environmentVariables. |
actionMappings → mappedAction → sourceType | string | true | Type of script file location can be ‘local' or 'git’ |
actionMappings → mappedAction → filepath | string | true | Location of script or executable file |
actionMappings → mappedAction → stdout | string | false | stdout filepath of action |
actionMappings → mappedAction → stderr | string | false | stderr filepath of action |
actionMappings → mappedAction → args | list of string | false | Execute arguments that applies to specified action |
actionMappings → mappedAction → flags | map of string key-value | false | Execute flags that applies to specified action |
actionMappings → mappedAction → env | list of strings | false | Each element indicates one environment variable name and value separated with ‘=’ character. Applies to specified action. (e.g., “ENV1=value”) |
actionMappings → mappedAction → gitOptions | map | true for git source | This field includes all three string properties, |
actionMappings → mappedAction → gitOptions → url | string | true for git source | HTTPS or SSH url of the git repository of the mappedAction |
actionMappings → mappedAction → gitOptions → privateKeyFilepath | string | false | Private key filepath of the git repository of the mappedAction (if needed) |
actionMappings → mappedAction → gitOptions → passphrase | string | false | Passphrase of the git repository of the mappedAction (if needed) |
pollerConf | map | false | The field gets all three integer properties specifying behavior of the poller that poll the sqs queue of OEC. |
pollerConf → pollingWaitIntervalInMillis | integer | false | The wait period of the poller when there is no new message in the queue or free job worker |
pollerConf → visibilityTimeoutInSeconds | integer | false | The visibility timeout of messages that are polled from sqs queue |
pollerConf → maxNumberOfMessages | integer | false | Maximum number of messages that are received at a time |
poolConf | map | false | The field gets all five integer properties specifying |
poolConf → maxNumberOfWorker | integer | false | Maximum number of worker processing action |
poolConf → minNumberOfWorker | integer | false | Minimum number of worker processing action |
poolConf → queueSize | integer | false | Internal queue size of messages that are received from sqs queue |
poolConf → keepAliveTimeInMillis | integer | false | Alive time limit for any worker that is idle when actual worker count is higher than minNumberOfWorker |
poolConf → monitoringPeriodInMillis | integer | false | Monitoring interval to record pool metrics |
Local variable of args, flags and env overrides global ones.
apiKey, opsgenieUrl (baseUrl) and payload (OEC callback as JSON) passes to args as flag format. These flags should be parsed in action scripts or executables.
Payload consists alert info and integration specific params. Integration-specific params will exist for “send via OEC” option.
OEC updates git repositories periodically every 1 minute.
OEC integration uses directly actual actions (e.g. Create, Close, Acknowledge, etc.), other integrations will use primarily "mappedAction" related with themselves (e.g. addCommentToIssue, createIssue, etc. for Jira integration).
Example of JSON File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
"appName": "OEC-Example",
"apiKey" : "4w3a0df7-d5c8-40d7-96db-975986bx3cb4",
"baseUrl" : "https://api.opsgenie.com",
"logLevel" : "debug",
"globalArgs" : ["globalArg"],
"_globalFlags" : {
"comment out" : "remove '_' sign to enable globalFlags",
"flagKey" : "flagValue"
},
"globalEnv" : ["globalEnv1=value"],
"actionMappings" : {
"Create" : {
"sourceType" : "local",
"filepath" : "~/Desktop/executable",
"args" : ["arg"],
"_flags": {
"comment out" : "remove '_' sign to enable flags",
"flagKey" : "flagValue"
},
"env" : ["env1=value"],
"stdout" : "~/Desktop/createOut.txt",
"stderr" : "~/Desktop/createErr.txt"
},
"Acknowledge" : {
"sourceType" : "git",
"filepath" : "/executable",
"gitOptions" : {
"url" : "https://bitbucket.org/example/example.git"
},
"stdout" : "~/Desktop/ackOut.txt",
"stderr" : "~/Desktop/ackErr.txt"
},
"Custom" : {
"sourceType" : "git",
"filepath" : "/executable",
"gitOptions" : {
"url" : "git@gitlab.com:example/example.git",
"privateKeyFilepath" : "~/.ssh/id_rsa",
"passphrase" : "pass"
}
}
},
"pollerConf" : {
"pollingWaitIntervalInMillis" : 100,
"visibilityTimeoutInSeconds" : 30,
"maxNumberOfMessages" : 10
},
"poolConf" : {
"maxNumberOfWorker": 12,
"minNumberOfWorker": 4,
"queueSize" : 0,
"keepAliveTimeInMillis" : 6000,
"monitoringPeriodInMillis" : 15000
}
}
Example of YAML File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
appName: OEC-Example
apiKey: 4w3a0df7-d5c8-40d7-96db-975986bx3cb4
baseUrl: https://api.opsgenie.com
logLevel: debug
globalArgs:
- globalArg
_globalFlags:
comment out: remove '_' sign to enable globalFlags
flagKey: flagValue
globalEnv:
- globalEnv1=value
actionMappings:
Create:
sourceType: local
filepath: "~/Desktop/executable"
args:
- arg
_flags:
comment out: remove '_' sign to enable flags
flagKey: flagValue
env:
- env1=value
stdout: "~/Desktop/createOut.txt"
stderr: "~/Desktop/createErr.txt"
Acknowledge:
sourceType: git
filepath: "/executable"
gitOptions:
url: https://bitbucket.org/example/example.git
stdout: "~/Desktop/ackOut.txt"
stderr: "~/Desktop/ackErr.txt"
Custom:
sourceType: git
filepath: "/executable"
gitOptions:
url: git@gitlab.com:example/example.git
privateKeyFilepath: "~/.ssh/id_rsa"
passphrase: pass
pollerConf:
pollingWaitIntervalInMillis: 100
visibilityTimeoutInSeconds: 30
maxNumberOfMessages: 10
poolConf:
maxNumberOfWorker: 12
minNumberOfWorker: 4
queueSize: 0
keepAliveTimeInMillis: 6000
monitoringPeriodInMillis: 15000
Was this helpful?