[Live Webinar] Next-Level O11y: Why Every DevOps Team Needs a RUM Strategy Register today!

Back to All Docs

Archive Setup gRPC API

Last Updated: Jun. 22, 2023

This tutorial will demonstrate how to use our Archive Setup API to:

  • View bucket definitions and set a target bucket (Get target / Set target)
  • Define archive retentions (Get, Update, Activate)

Prerequisites

  • Coralogix Alerts, Rules & Tags API Key (Access this in your navigation pane by clicking Data Flow > API Keys)
  • Management API endpoint

Supported API Calls

The API supports the following gRPCs:

Examples

rpc GetTarget(GetTargetRequest) returns (GetTargetResponse)

GetTargetRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.TargetService/GetTarget <<EOF
{
}
EOF

GetTargetResponse

{
  "target": {
    "archivingFormatId": "cx_data_v1",
    "isActive": true,
    "region": "eu-west-1",
    "bucket": "example-bucket",
    "enableTags": false
  }
}
FieldTypeDescription
archivingFormatIdstringFormat of the archive log files
isActivebooleanIndicates whether archive is active
regionstringAWS region in which your s3 bucket is located
bucketstringS3 bucket name
enableTagsbooleanIndicates whether retention tagging feature in enabled

rpc SetTarget(SetTargetRequest) returns (SetTargetResponse)

SetTargetRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.TargetService/SetTarget <<EOF
{
    "bucket": "example-bucket",
    "is_active": true
}
EOF
FieldTypeDescription
bucketstringS3 bucket name
is_activebooleanActivate / deactivate archive

SetTargetResponse

{
  "target": {
    "archivingFormatId": "cx_data_v1",
    "isActive": true,
    "region": "eu-west-1",
    "bucket": "example-bucket",
    "enableTags": false
  }
}
FieldTypeDescription
archivingFormatIdstringFormat of the archive log files
isActivebooleanIndicates whether archive is active
regionstringAWS region in which your s3 bucket is located
bucketstringS3 bucket name
enableTagsbooleanIndicates whether retention tagging feature in enabled

rpc GetRetentionsEnabled(GetRetentionsEnabledRequest) returns (GetRetentionsEnabledResponse)

GetRetentionsEnabledRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.RetentionsService/GetRetentionsEnabled <<EOF
{
}
EOF

GetRetentionsEnabledResponse

{
  "enableTags": false
}
FieldTypeDescription
enableTagsbooleanIndicates whether retention tagging feature in enabled

rpc GetRetentions(GetRetentionsRequest) returns (GetRetentionsResponse)

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.RetentionsService/GetRetentions <<EOF
{
}
EOF

GetRetentionsRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.RetentionsService/GetRetentions <<EOF
{
}
EOF

GetRetentionsResponse

{
  "retentions": [
    {
      "id": "c157476b-642d-400d-9acf-40f3ab02721a",
      "order": 1,
      "name": "Default",
      "editable": false
    },
    {
      "id": "485a2668-e815-4ec1-9b22-0228f5a27dc8",
      "order": 2,
      "name": "short",
      "editable": true
    },
    {
      "id": "3dacd60d-f83e-40f2-bf36-e7d2657a98d1",
      "order": 3,
      "name": "Intermediate",
      "editable": true
    },
    {
      "id": "ba29d452-966b-4ca7-8234-dc2d9bbe2d5e",
      "order": 4,
      "name": "Long",
      "editable": true
    }
  ]
}
FieldTypeDescription
retentionsarrayArray of retention elements
retentions[].idstringRetention ID to be used in TCO policy API
retentions[].ordernumberHas no significance. Currently only 4 retentions are supported
retentions[].namestringRetention name, which can be changed (except ‘default’)
retentions[].editablebooleanWhether retention is editable (All but ‘default’ are editable)

rpc UpdateRetentions(UpdateRetentionsRequest) returns (UpdateRetentionsResponse)

UpdateRetentionsRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.RetentionsService/UpdateRetentions <<EOF
{
  "retention_update_elements": [
    {
      "id": "485a2668-e815-4ec1-9b22-0228f5a27dc8",
      "name": "1_week"
    },
    {
      "id": "e9ee9138-4533-463d-a93b-bb18692208a5",
      "name": "1_month"
    }
  ]
}
EOF
FieldTypeDescription
retention_update_elementsArrayArray of retention elements
retention_update_elements[].idstringID of the retention to update
retention_update_elements[].namestringName of the retention to update

UpdateRetentionsResponse

{
  "retentions": [
    {
      "id": "485a2668-e815-4ec1-9b22-0228f5a27dc8",
      "order": 2,
      "name": "1_week",
      "editable": true
    },
    {
      "id": "3dacd60d-f83e-40f2-bf36-e7d2657a98d1",
      "order": 3,
      "name": "1_month",
      "editable": true
    }
  ]
}

rpc ActivateRetentions(ActivateRetentionsRequest) returns (ActivateRetentionsResponse)

ActivateRetentionsRequest

grpcurl -H "Authorization: Bearer <YOUR-API-KEY>" -d @ <CORALOGIX-DOMAIN> com.coralogix.archive.v1.RetentionsService/ActivateRetentions <<EOF
{
}
EOF

ActivateRetentionsResponse

{
  "activateRetentions": true
}
FieldTypeDescription
activateRetentionsbooleanTrue, if activated

If missing tagging permissions on a bucket, response will be the following error:

ERROR:
  Code: FailedPrecondition
  Message: Failed to update archive retention policy. Please provide Coralogix with tagging permissions in your AWS dashboard and try again.

Additional Resources

DocumentationArchive Retention Policy
TCO Optimizer
TCO Optimizer API

Support

Need help?

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us via our in-app chat or by sending us an email at [email protected].

On this page

Live Webinar
Next-Level O11y: Why Every DevOps Team Needs a RUM Strategy
April 30th at 12pm ET | 6pm CET
Save my Seat