Elasticsearch Connection
General Information
Connection Type
elasticsearch
UI Documentation
📖 For detailed information: [UI Documentation Link - Link will be added here]
Description
Elasticsearch connection for indexing and querying data in Elasticsearch clusters. Used by policies and other components that need to store logs, metrics, or other data in Elasticsearch. Supports authentication, encryption, index lifecycle management, and index templates.
Endpoints
List Connections
GET /apiops/projects/{projectName}/connections/?type=elasticsearch
Get Connection
GET /apiops/projects/{projectName}/connections/{connectionName}/
Create Connection
POST /apiops/projects/{projectName}/connections/{connectionName}/
Update Connection
PUT /apiops/projects/{projectName}/connections/{connectionName}/
Delete Connection
DELETE /apiops/projects/{projectName}/connections/{connectionName}/
List Connections
Endpoint
GET /apiops/projects/{projectName}/connections/?type=elasticsearch
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
Note: The type query parameter is required to filter connections by type.
cURL Example
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/" \
-H "Authorization: Bearer YOUR_TOKEN"
Get Connection
Endpoint
GET /apiops/projects/{projectName}/connections/{connectionName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| connectionName | string | Yes | Connection name |
Response
Success Response (200 OK)
{
"success": true,
"resultList": [
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection for logging",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "http",
"host": "localhost",
"port": 9200
},
{
"scheme": "https",
"host": "elasticsearch.example.com",
"port": 9200
}
],
"authenticate": true,
"elasticUsername": "elastic",
"elasticPassword": null,
"encryptCommunication": true,
"encryptCommunicationType": "CA_CERTIFICATE_IN_PKCS_12",
"caCertInPkcs12File": null,
"caCertInPkcs12FileContentType": "application/x-pkcs12",
"caInPemFile": null,
"caInPemFileContentType": null,
"caTruststoreFile": null,
"caTruststoreFileContentType": null,
"caTruststoreFilePass": null,
"caKeystoreFile": null,
"caKeystoreFileContentType": null,
"caKeystoreFilePass": null,
"disableHostnameVerification": false,
"indexLifecyclePolicyCreated": true,
"indexLifecyclePolicy": {
"policyName": "apinizer-log-ilm-policy-default",
"enableHotPhase": true,
"maxAgeOfRollover": 30,
"maxIndexSizeOfRollover": 30,
"maxDocCountOfRollover": 15000000,
"enableWarmPhase": true,
"numberOfReplicasForWarm": 0,
"maxNumShardsForShrink": 1,
"maxNumSegmentsForForceMerge": 1,
"enableColdPhase": true,
"minAgeOfCold": 90,
"numberOfReplicasForCold": 0,
"enableDeletePhase": true,
"minAgeOfDelete": 365
},
"indexTemplateCreated": true,
"indexTemplateName": "apinizer-log-template",
"indexName": "apinizer-logs",
"indexTemplateNumberOfShards": 1,
"indexTemplateNumberOfReplicas": 1,
"indexTemplateRefreshInterval": "1s",
"connectionTimeoutInMs": 5000,
"socketReuseAddress": true,
"socketKeepAlive": true,
"ioThreads": 1,
"maxConnectionPerHost": 10,
"maxConnectionTotal": 20,
"type": "READ_WRITE"
}
],
"resultCount": 1
}
Note: Secret fields are masked in get operations.
cURL Example
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/my-elasticsearch-connection/" \
-H "Authorization: Bearer YOUR_TOKEN"
Create Connection
Endpoint
POST /apiops/projects/{projectName}/connections/{connectionName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| connectionName | string | Yes | Connection name |
Request Body
Full JSON Body Example - Basic Configuration
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection for logging",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "http",
"host": "localhost",
"port": 9200
}
],
"authenticate": false,
"elasticUsername": null,
"elasticPassword": null,
"encryptCommunication": false,
"encryptCommunicationType": null,
"caCertInPkcs12File": null,
"caCertInPkcs12FileContentType": null,
"caInPemFile": null,
"caInPemFileContentType": null,
"caTruststoreFile": null,
"caTruststoreFileContentType": null,
"caTruststoreFilePass": null,
"caKeystoreFile": null,
"caKeystoreFileContentType": null,
"caKeystoreFilePass": null,
"disableHostnameVerification": false,
"indexLifecyclePolicyCreated": false,
"indexLifecyclePolicy": null,
"indexTemplateCreated": false,
"indexTemplateName": null,
"indexName": null,
"indexTemplateNumberOfShards": null,
"indexTemplateNumberOfReplicas": null,
"indexTemplateRefreshInterval": null,
"connectionTimeoutInMs": null,
"socketReuseAddress": null,
"socketKeepAlive": null,
"ioThreads": null,
"maxConnectionPerHost": null,
"maxConnectionTotal": null,
"type": "READ_WRITE"
}
Full JSON Body Example - With Authentication
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection with authentication",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "https",
"host": "elasticsearch.example.com",
"port": 9200
}
],
"authenticate": true,
"elasticUsername": "elastic",
"elasticPassword": "changeme",
"encryptCommunication": false,
"encryptCommunicationType": null,
"disableHostnameVerification": false,
"type": "READ_WRITE"
}
Full JSON Body Example - With Encryption (PKCS12)
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection with PKCS12 encryption",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "https",
"host": "elasticsearch.example.com",
"port": 9200
}
],
"authenticate": true,
"elasticUsername": "elastic",
"elasticPassword": "changeme",
"encryptCommunication": true,
"encryptCommunicationType": "CA_CERTIFICATE_IN_PKCS_12",
"caCertInPkcs12File": "<base64-encoded-pkcs12-file>",
"caCertInPkcs12FileContentType": "application/x-pkcs12",
"caInPemFile": null,
"caInPemFileContentType": null,
"caTruststoreFile": null,
"caTruststoreFileContentType": null,
"caTruststoreFilePass": "keystore-password",
"caKeystoreFile": null,
"caKeystoreFileContentType": null,
"caKeystoreFilePass": null,
"disableHostnameVerification": false,
"type": "READ_WRITE"
}
Full JSON Body Example - With Encryption (PEM)
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection with PEM encryption",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "https",
"host": "elasticsearch.example.com",
"port": 9200
}
],
"authenticate": true,
"elasticUsername": "elastic",
"elasticPassword": "changeme",
"encryptCommunication": true,
"encryptCommunicationType": "CA_IN_PEM_FILE",
"caCertInPkcs12File": null,
"caCertInPkcs12FileContentType": null,
"caInPemFile": "<base64-encoded-pem-file>",
"caInPemFileContentType": "application/x-pem-file",
"caTruststoreFile": null,
"caTruststoreFileContentType": null,
"caTruststoreFilePass": null,
"caKeystoreFile": null,
"caKeystoreFileContentType": null,
"caKeystoreFilePass": null,
"disableHostnameVerification": false,
"type": "READ_WRITE"
}
Full JSON Body Example - With Index Lifecycle Policy and Template
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection with ILM and template",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "http",
"host": "localhost",
"port": 9200
}
],
"authenticate": false,
"encryptCommunication": false,
"indexLifecyclePolicyCreated": true,
"indexLifecyclePolicy": {
"policyName": "apinizer-log-ilm-policy",
"enableHotPhase": true,
"maxAgeOfRollover": 30,
"maxIndexSizeOfRollover": 30,
"maxDocCountOfRollover": 15000000,
"enableWarmPhase": true,
"numberOfReplicasForWarm": 0,
"maxNumShardsForShrink": 1,
"maxNumSegmentsForForceMerge": 1,
"enableColdPhase": true,
"minAgeOfCold": 90,
"numberOfReplicasForCold": 0,
"enableDeletePhase": true,
"minAgeOfDelete": 365
},
"indexTemplateCreated": true,
"indexTemplateName": "apinizer-log-template",
"indexName": "apinizer-logs",
"indexTemplateNumberOfShards": 1,
"indexTemplateNumberOfReplicas": 1,
"indexTemplateRefreshInterval": "1s",
"connectionTimeoutInMs": 5000,
"socketReuseAddress": true,
"socketKeepAlive": true,
"ioThreads": 1,
"maxConnectionPerHost": 10,
"maxConnectionTotal": 20,
"type": "READ_WRITE"
}
Request Body Fields
Common Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | Yes | - | Connection type discriminator field. Identifies the connection type in API requests/responses. |
| name | string | Yes | - | Connection name (must match path parameter) |
| description | string | No | - | Connection description |
| deployToWorker | boolean | No | true | Whether to deploy to worker |
| enabled | boolean | No | true | Whether connection is enabled |
Elasticsearch-Specific Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| administrate | boolean | No | false | Whether to administrate Elasticsearch (create/delete indices, templates, policies) |
| elasticHostList | array | Yes | - | List of Elasticsearch hosts. See ElasticHost |
| authenticate | boolean | No | false | Enable authentication |
| elasticUsername | string | No* | null | Elasticsearch username (required if authenticate=true) |
| elasticPassword | string | No* | null | Elasticsearch password (required if authenticate=true, secret field) |
| encryptCommunication | boolean | No | false | Enable encrypted communication (HTTPS) |
| encryptCommunicationType | string | No* | null | Encryption communication type (required if encryptCommunication=true). See EnumEncryptCommunicationType |
| caCertInPkcs12File | string | No* | null | CA certificate in PKCS12 format (base64-encoded, required if encryptCommunicationType=CA_CERTIFICATE_IN_PKCS_12) |
| caCertInPkcs12FileContentType | string | No | application/x-pkcs12 | Content type for PKCS12 file |
| caInPemFile | string | No* | null | CA certificate in PEM format (base64-encoded, required if encryptCommunicationType=CA_IN_PEM_FILE) |
| caInPemFileContentType | string | No | application/x-pem-file | Content type for PEM file |
| caTruststoreFile | string | No* | null | CA truststore file (base64-encoded, used with PKCS12) |
| caTruststoreFileContentType | string | No | application/x-pkcs12 | Content type for truststore file |
| caTruststoreFilePass | string | No | null | Truststore file password (secret field) |
| caKeystoreFile | string | No* | null | CA keystore file (base64-encoded, required if encryptCommunicationType=CERT_AND_PRIVATE_KEY_IN_PKCS_12) |
| caKeystoreFileContentType | string | No | application/x-pkcs12 | Content type for keystore file |
| caKeystoreFilePass | string | No* | null | Keystore file password (required if caKeystoreFile is provided, secret field) |
| disableHostnameVerification | boolean | No | false | Disable hostname verification (not recommended for production) |
| indexLifecyclePolicyCreated | boolean | No | false | Whether to create index lifecycle policy |
| indexLifecyclePolicy | object | No* | null | Index lifecycle policy configuration (required if indexLifecyclePolicyCreated=true). See ElasticsearchIndexLifecyclePolicy |
| indexTemplateCreated | boolean | No | false | Whether to create index template |
| indexTemplateName | string | No* | null | Index template name (required if indexTemplateCreated=true) |
| indexName | string | No | null | Index name pattern |
| indexTemplateNumberOfShards | integer | No | null | Number of shards for index template |
| indexTemplateNumberOfReplicas | integer | No | null | Number of replicas for index template |
| indexTemplateRefreshInterval | string | No | null | Refresh interval for index template (e.g., “1s”, “5s”) |
| connectionTimeoutInMs | integer | No | null | Connection timeout in milliseconds |
| socketReuseAddress | boolean | No | null | Reuse socket address |
| socketKeepAlive | boolean | No | null | Keep socket alive |
| ioThreads | integer | No | null | Number of IO threads |
| maxConnectionPerHost | integer | No | null | Maximum connections per host |
| maxConnectionTotal | integer | No | null | Maximum total connections |
| type | string | No | READ_WRITE | Elasticsearch connection type. See EnumElasticsearchType |
EnumEncryptCommunicationType
CA_CERTIFICATE_IN_PKCS_12- CA certificate is available in a PKCS#12 keystoreCA_IN_PEM_FILE- CA certificate is available as a PEM encoded fileCERT_AND_PRIVATE_KEY_IN_PKCS_12- Certificate and a private key that are stored in a PKCS#12 keystore
EnumElasticsearchType
READ_WRITE- Read and write access (can create indices, templates, policies)READ- Read-only access (can only query, cannot create/modify)
Note
elasticHostListmust contain at least one host.- If
authenticate: true, bothelasticUsernameandelasticPasswordare required. - If
encryptCommunication: true,encryptCommunicationTypeis required. - If
encryptCommunicationType: CA_CERTIFICATE_IN_PKCS_12,caCertInPkcs12Fileis required. - If
encryptCommunicationType: CA_IN_PEM_FILE,caInPemFileis required. - If
encryptCommunicationType: CERT_AND_PRIVATE_KEY_IN_PKCS_12,caKeystoreFileandcaKeystoreFilePassare required. - If
indexLifecyclePolicyCreated: true,indexLifecyclePolicyis required. - If
indexTemplateCreated: true,indexTemplateNameis required.
ElasticHost
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| scheme | string | No | http | URL scheme: http or https |
| host | string | Yes | - | Elasticsearch hostname or IP address |
| port | integer | No | 9200 | Elasticsearch port |
Note: At least one host is required in elasticHostList.
ElasticsearchIndexLifecyclePolicy
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| policyName | string | No | apinizer-log-ilm-policy-default | Index lifecycle policy name |
| enableHotPhase | boolean | No | false | Enable hot phase |
| maxAgeOfRollover | integer | No | null | Maximum age for rollover (in days) |
| maxIndexSizeOfRollover | integer | No | null | Maximum index size for rollover (in GB) |
| maxDocCountOfRollover | long | No | null | Maximum document count for rollover |
| enableWarmPhase | boolean | No | false | Enable warm phase |
| numberOfReplicasForWarm | integer | No | null | Number of replicas for warm phase |
| maxNumShardsForShrink | integer | No | null | Maximum number of shards for shrink |
| maxNumSegmentsForForceMerge | integer | No | null | Maximum number of segments for force merge |
| enableColdPhase | boolean | No | false | Enable cold phase |
| minAgeOfCold | integer | No | null | Minimum age for cold phase (in days) |
| numberOfReplicasForCold | integer | No | null | Number of replicas for cold phase |
| enableDeletePhase | boolean | No | false | Enable delete phase |
| minAgeOfDelete | integer | No | null | Minimum age for delete phase (in days) |
Note
- Age values are in days.
- Size values are in GB.
- At least one phase must be enabled.
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
cURL Example
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/connections/my-elasticsearch-connection/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection for logging",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "http",
"host": "localhost",
"port": 9200
}
],
"authenticate": false,
"encryptCommunication": false,
"type": "READ_WRITE"
}'
Update Connection
Endpoint
PUT /apiops/projects/{projectName}/connections/{connectionName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| connectionName | string | Yes | Connection name (must match name in body) |
Request Body
Full JSON Body Example
{
"type": "elasticsearch",
"name": "my-elasticsearch-connection",
"description": "Elasticsearch connection for logging",
"deployToWorker": true,
"enabled": true,
"administrate": true,
"elasticHostList": [
{
"scheme": "http",
"host": "localhost",
"port": 9200
}
],
"authenticate": false,
"elasticUsername": null,
"elasticPassword": null,
"encryptCommunication": false,
"encryptCommunicationType": null,
"caCertInPkcs12File": null,
"caCertInPkcs12FileContentType": null,
"caInPemFile": null,
"caInPemFileContentType": null,
"caTruststoreFile": null,
"caTruststoreFileContentType": null,
"caTruststoreFilePass": null,
"caKeystoreFile": null,
"caKeystoreFileContentType": null,
"caKeystoreFilePass": null,
"disableHostnameVerification": false,
"indexLifecyclePolicyCreated": false,
"indexLifecyclePolicy": null,
"indexTemplateCreated": false,
"indexTemplateName": null,
"indexName": null,
"indexTemplateNumberOfShards": null,
"indexTemplateNumberOfReplicas": null,
"indexTemplateRefreshInterval": null,
"connectionTimeoutInMs": null,
"socketReuseAddress": null,
"socketKeepAlive": null,
"ioThreads": null,
"maxConnectionPerHost": null,
"maxConnectionTotal": null,
"type": "READ_WRITE"
}
Note: Request body structure is the same as Create Connection. All fields should be provided for update.
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [...]
}
}
Delete Connection
Endpoint
DELETE /apiops/projects/{projectName}/connections/{connectionName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| connectionName | string | Yes | Connection name |
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [...]
}
}
Notes and Warnings
- Elasticsearch Hosts:
- At least one host is required in
elasticHostList - Multiple hosts can be specified for high availability
- Each host must have
scheme(http/https),host, andport
- At least one host is required in
- Authentication:
- When
authenticate: true, bothelasticUsernameandelasticPasswordare required - Supports basic authentication
- Password is stored securely and masked in responses
- When
- Encryption:
encryptCommunication: trueenables HTTPS/TLS- Three encryption types supported:
CA_CERTIFICATE_IN_PKCS_12- CA certificate in PKCS12 keystoreCA_IN_PEM_FILE- CA certificate in PEM fileCERT_AND_PRIVATE_KEY_IN_PKCS_12- Certificate and private key in PKCS12 keystore
- Certificate files must be base64-encoded
- Index Lifecycle Management:
indexLifecyclePolicyCreated: truecreates an ILM policy- Supports hot, warm, cold, and delete phases
- Helps manage index lifecycle automatically
- Index Templates:
indexTemplateCreated: truecreates an index template- Template defines index settings (shards, replicas, refresh interval)
- Used for automatic index creation
- Connection Settings:
connectionTimeoutInMs- Connection timeoutsocketReuseAddress,socketKeepAlive- Socket optionsioThreads- Number of IO threadsmaxConnectionPerHost,maxConnectionTotal- Connection pool limits
- Connection Type:
READ_WRITE- Full access (can create indices, templates, policies)READ- Read-only access (query only)
- Administration:
administrate: trueallows creating/deleting indices, templates, and policies- Requires appropriate Elasticsearch permissions
- Performance: Connection pooling and timeout settings affect performance. Tune based on workload.
- Security:
- Use HTTPS in production
- Enable authentication
- Do not disable hostname verification in production
- Store certificates securely
- Deployment: Connection changes require deployment to take effect. Set
deployToWorker: trueor deploy manually.
Related Documentation
- List Connections - List all connections
- Get Connection - Get a specific connection
- Create Connection - General connection creation guide
- Update Connection - General connection update guide
- Delete Connection - General connection deletion guide