1. coralogix/coralogix@0.11.0

coralogix/coralogix@0.11.0

Partner
Sections
Integrate your CircleCI workflows and jobs pipeline with Coralogix to automatically receive reports and analyze version upgrades for their impact on the overall quality of your production system. Learn more: https://coralogix.com/category/tutorials/
Created: November 8, 2019Version Published: September 11, 2023Releases: 12
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: coralogix: coralogix/coralogix@0.11.0

Use coralogix elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

logs

This example shows how you can debug a workflow job in Coralogix. By adding our Orb and the coralogix/logs job at the end of the flow, you'll receive all logs CircleCI generates during the workflow in your Coralogix account, helping you debug the different jobs. Note that this may generate a large amount of data, and is recommended for debugging purposes only.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 version: '2.1' orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Typical build job" workflows: your-workflow: jobs: - build - coralogix/logs

send

This example shows how you can send additional 3rd party logs generated during your workflow job to Coralogix. By adding our Orb and the coralogix/send step, you can send additional logs from an external file to your Coralogix account. This is especially useful if one of the stages of your job generates an external file with logs which you'd like to report to Coralogix and analyze along with the rest of your logs.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 version: '2.1' orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Build the application" > build.log - coralogix/send: file: build.log workflows: your-workflow: jobs: - build

stats

This example shows how you can send the final report of a workflow job to Coralogix. By adding our Orb and the coralogix/stats job at the end of the flow, you'll receive the report automatically in your Coralogix account and can analyze and aggregate the results.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 version: '2.1' orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Typical build job" workflows: your-workflow: jobs: - build - coralogix/stats

tag

This example shows how you can create a tag (and a report) for the workflow in Coralogix. By adding our Orb and the coralogix/tag step, you can create tag (and a report) for this workflow in your Coralogix account to understand what effect it has on your production. Learn more at https://coralogix.com/tutorials/software-builds-display/

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 version: '2.1' orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Build the application" deploy: docker: - image: cimg/base:stable steps: - run: echo "Deploy the application" - coralogix/tag: application: MyApp subsystems: frontend,backend tag: v1.0.0 test: docker: - image: cimg/base:stable steps: - run: echo "Test the application" workflows: your-workflow: jobs: - build - test: requires: - build - deploy: requires: - test

Jobs

logs

This job is used to debug CircleCI workflow jobs in Coralogix by sending all the debug logs. Note that this may generate a large amount of data, and is recommended for debugging purposes only.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
application
Your application name.
No
CircleCI
string
category
The log's category.
No
logs
string
circle-token
Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api
No
CIRCLE_TOKEN
env_var_name
endpoint
Coralogix API endpoint.
No
api.coralogix.com
string
hostname
Machine hostname.
No
$(hostname)
string
keep_artifacts
Keep temporary log files generated during the job after being sent to coralogix.
No
false
boolean
private_key
Private key provided by Coralogix (under Settings --> Send Your Logs).
No
CORALOGIX_PRIVATE_KEY
env_var_name
subsystem
Your subsystem name.
No
workflow-logs
string

stats

This job is used to get the final report of a workflow job in Coralogix where you can analyzea and aggregate the results.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
application
Your application name.
No
CircleCI
string
category
The log's category.
No
logs
string
circle-token
Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api
No
CIRCLE_TOKEN
env_var_name
endpoint
Coralogix API endpoint.
No
api.coralogix.com
string
hostname
Machine hostname.
No
$(hostname)
string
keep_artifacts
Keep temporary log files generated during the job after being sent to coralogix.
No
false
boolean
private_key
Private key provided by Coralogix (under Settings --> Send Your Logs).
No
CORALOGIX_PRIVATE_KEY
env_var_name
subsystem
Your subsystem name.
No
workflow-stats
string

Commands

send

This command is used to send additional 3rd party logs generated during your workflow job to Coralogix.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
application
Your application name.
No
CircleCI
string
category
The log's category.
No
artifact
string
class
The log's class name.
No
''
string
endpoint
Coralogix API endpoint.
No
api.coralogix.com
string
file
Absolute or relative path to the file for sending.
Yes
-
string
hostname
Machine hostname.
No
$(hostname)
string
method
The log's method name.
No
''
string
newline_pattern
Regular expression to split records in the file.
No
\n|\r|\r\n
string
private_key
Private key provided by Coralogix (under Settings --> Send Your Logs).
No
CORALOGIX_PRIVATE_KEY
env_var_name
subsystem
Your subsystem name.
No
workflow
string
thread
Thread ID reported with the log.
No
${CIRCLE_WORKFLOW_ID}
string

tag

This command is used to create a tag (and a report) for the workflow in Coralogix, helping you understand what effect it has on your production. Learn more at https://coralogix.com/tutorials/software-builds-display/

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
api_key
API key provided by Coralogix (under Settings --> Account --> API Access).
No
CORALOGIX_API_KEY
env_var_name
applications
Your application name. You can set more than one application name by using ',' comma as a delimiter between applications names.
Yes
-
string
endpoint
Coralogix API endpoint.
No
webapi.coralogix.com
string
icon
A custom image to use for your tag. URL should point to a valid image file that is publicly available (png, jpeg, SVG). Max size 50KB.
No
''
string
subsystems
Your subsystem names. You can set more than one subsystem name by using ',' comma as a delimiter between subsystems names.
Yes
-
string
tag
Name presented for the tag.
Yes
-
string

workflow

Defines the command to help ship workflow logs to Coralogix.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
circle-token
Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api
No
CIRCLE_TOKEN
env_var_name
keep_artifacts
Keep generated workflow data.
No
false
boolean

Executors

default

Default environment for Coralogix.

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
image
Docker image name
No
cimg/base
string
tag
Docker image tag
No
stable
string

Orb Source

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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/ja/orbs/licensing version: 2.1 description: | Integrate your CircleCI workflows and jobs pipeline with Coralogix to automatically receive reports and analyze version upgrades for their impact on the overall quality of your production system. Learn more: https://coralogix.com/category/tutorials/ display: home_url: https://coralogix.com source_url: https://github.com/coralogix-circleci/coralogix-orb orbs: jq: circleci/jq@2.2.1 commands: send: description: | This command is used to send additional 3rd party logs generated during your workflow job to Coralogix. parameters: application: default: CircleCI description: Your application name. type: string category: default: artifact description: The log's category. type: string class: default: "" description: The log's class name. type: string endpoint: default: api.coralogix.com description: Coralogix API endpoint. type: string file: description: Absolute or relative path to the file for sending. type: string hostname: default: $(hostname) description: Machine hostname. type: string method: default: "" description: The log's method name. type: string newline_pattern: default: \n|\r|\r\n description: Regular expression to split records in the file. type: string private_key: default: CORALOGIX_PRIVATE_KEY description: Private key provided by Coralogix (under Settings --> Send Your Logs). type: env_var_name subsystem: default: workflow description: Your subsystem name. type: string thread: default: ${CIRCLE_WORKFLOW_ID} description: Thread ID reported with the log. type: string steps: - jq/install - run: command: | if [ ! -f "<<parameters.file>>" ]; then echo "File not found!" exit 0 fi LOG_FILE=$(realpath "<<parameters.file>>") LOG_BULKS=$(mktemp -d) pushd $LOG_BULKS split -C 2M -d "$LOG_FILE" '' popd for bulk in $LOG_BULKS/*; do jq -nMc \ --rawfile lines "$bulk" \ --arg private_key "${<<parameters.private_key>>}" \ --arg application "<<parameters.application>>" \ --arg subsystem "<<parameters.subsystem>>" \ --arg hostname "<<parameters.hostname>>" \ --arg category "<<parameters.category>>" \ --arg class "<<parameters.class>>" \ --arg method "<<parameters.method>>" \ --arg thread "<<parameters.thread>>" '{ "privateKey": $private_key, "applicationName": $application, "subsystemName": $subsystem, "computerName": $hostname, "logEntries": [ $lines | split("<<parameters.newline_pattern>>"; "") | to_entries | .[] | { "timestamp": (now * 1000 + .key), "severity": 3, "text": .value | select(.!=""), "category": $category, "className": $class, "methodName": $method, "threadId": $thread } ] }' | curl -X POST -H 'Content-Type: application/json' -d @- -s 'https://<<parameters.endpoint>>/api/v1/logs' done rm -rf "$LOG_BULKS" name: Send to Coralogix when: always tag: description: | This command is used to create a tag (and a report) for the workflow in Coralogix, helping you understand what effect it has on your production. Learn more at https://coralogix.com/tutorials/software-builds-display/ parameters: api_key: default: CORALOGIX_API_KEY description: API key provided by Coralogix (under Settings --> Account --> API Access). type: env_var_name applications: description: | Your application name. You can set more than one application name by using ',' comma as a delimiter between applications names. type: string endpoint: default: webapi.coralogix.com description: Coralogix API endpoint. type: string icon: default: "" description: | A custom image to use for your tag. URL should point to a valid image file that is publicly available (png, jpeg, SVG). Max size 50KB. type: string subsystems: description: | Your subsystem names. You can set more than one subsystem name by using ',' comma as a delimiter between subsystems names. type: string tag: description: Name presented for the tag. type: string steps: - run: command: | jq -nMc \ --arg name "<<parameters.tag>>" \ --arg applications "<<parameters.applications>>" \ --arg subsystems "<<parameters.subsystems>>" \ --arg icon "<<parameters.icon>>" '{ "timestamp": (now * 1000), "name": $name, "application": $applications | split(","), "subsystem": $subsystems | split(",") } | if $icon != "" then .iconUrl |= $icon else . end' | curl -X POST -H "Authorization: Bearer ${<<parameters.api_key>>}" -H "Content-Type: application/json" -d @- -sSL 'https://<<parameters.endpoint>>/api/v1/external/tags' name: Push Coralogix Tag workflow: description: | Defines the command to help ship workflow logs to Coralogix. parameters: circle-token: default: CIRCLE_TOKEN description: | Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api type: env_var_name keep_artifacts: default: false description: Keep generated workflow data. type: boolean steps: - run: command: | if [ -z "${<<parameters.circle-token>>}" ]; then echo "CircleCI API token is not set!" exit 0 fi WORKFLOW=$(curl -s -H "Circle-Token: ${<<parameters.circle-token>>}" "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID") WORKFLOW_JOBS=$(curl -s -H "Circle-Token: ${<<parameters.circle-token>>}" "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" | jq '.items | map(select(.name|test("^coralogix/(stats|logs)")|not))') WORKFLOW_LENGTH=$(echo "$WORKFLOW_JOBS" | jq 'length') PROJECT_SLUG=$(echo "$WORKFLOW" | jq -r '.project_slug') mkdir -p /tmp/coralogix rm -f /tmp/coralogix/workflow-*.log for (( i=0; i<$WORKFLOW_LENGTH; )); do WORKFLOW_JOBS=$(curl -s -H "Circle-Token: ${<<parameters.circle-token>>}" "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" | jq '.items | map(select(.name|test("^coralogix/(stats|logs)")|not))') JOB_NUMBER=$(echo "$WORKFLOW_JOBS" | jq -r ".[$i].job_number") JOB_NAME=$(echo "$WORKFLOW_JOBS" | jq -r ".[$i].name") JOB_STATUS=$(echo "$WORKFLOW_JOBS" | jq -r ".[$i].status") echo "Checking $((i+1))/$WORKFLOW_LENGTH job $JOB_NAME($JOB_NUMBER) - $JOB_STATUS..." if [ "$JOB_STATUS" == "success" ] || [ "$JOB_STATUS" == "failed" ]; then if [ "$JOB_NUMBER" != "null" ]; then echo "Collecting data for job $JOB_NAME..." JOB=$(curl -s -H "Circle-Token: ${<<parameters.circle-token>>}" "https://circleci.com/api/v1.1/project/$PROJECT_SLUG/$JOB_NUMBER") JOB_LOGS=$(echo "$JOB" | jq '.steps[].actions[].output_url | select(.!=null)') if [ -z "$JOB_LOGS" ]; then sleep 10 continue fi echo "$JOB" | jq -c 'del(.steps, .circle_yml)' >> /tmp/coralogix/workflow-stats.log echo "$JOB_LOGS" | xargs -n1 curl -s --output - --compressed | jq -r '.[].message' >> /tmp/coralogix/workflow-logs.log echo "Job $JOB_NAME is successfully added to report..." else echo "Job $JOB_NAME is approval. Skipping..." fi elif [ "$JOB_STATUS" == "blocked" ] || [ "$JOB_STATUS" == "on_hold" ] || [ "$JOB_STATUS" == "canceled" ]; then echo "Job $JOB_NAME is $JOB_STATUS. Skipping..." else echo "Job $JOB_NAME is $JOB_STATUS..." sleep 10 continue fi i="$((i+1))" done name: Build workflow data when: always - when: condition: <<parameters.keep_artifacts>> steps: - store_artifacts: path: /tmp/coralogix executors: default: description: | Default environment for Coralogix. docker: - image: <<parameters.image>>:<<parameters.tag>> parameters: image: default: cimg/base description: Docker image name type: string tag: default: stable description: Docker image tag type: string resource_class: small jobs: logs: description: | This job is used to debug CircleCI workflow jobs in Coralogix by sending all the debug logs. Note that this may generate a large amount of data, and is recommended for debugging purposes only. executor: default parameters: application: default: CircleCI description: Your application name. type: string category: default: logs description: The log's category. type: string circle-token: default: CIRCLE_TOKEN description: | Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api type: env_var_name endpoint: default: api.coralogix.com description: Coralogix API endpoint. type: string hostname: default: $(hostname) description: Machine hostname. type: string keep_artifacts: default: false description: Keep temporary log files generated during the job after being sent to coralogix. type: boolean private_key: default: CORALOGIX_PRIVATE_KEY description: Private key provided by Coralogix (under Settings --> Send Your Logs). type: env_var_name subsystem: default: workflow-logs description: Your subsystem name. type: string steps: - workflow: circle-token: <<parameters.circle-token>> keep_artifacts: <<parameters.keep_artifacts>> - send: application: <<parameters.application>> category: <<parameters.category>> endpoint: <<parameters.endpoint>> file: /tmp/coralogix/workflow-logs.log hostname: <<parameters.hostname>> private_key: <<parameters.private_key>> subsystem: <<parameters.subsystem>> stats: description: | This job is used to get the final report of a workflow job in Coralogix where you can analyzea and aggregate the results. executor: default parameters: application: default: CircleCI description: Your application name. type: string category: default: logs description: The log's category. type: string circle-token: default: CIRCLE_TOKEN description: | Your CircleCI personal access token for interacting with the API. You can generate one here: https://circleci.com/account/api type: env_var_name endpoint: default: api.coralogix.com description: Coralogix API endpoint. type: string hostname: default: $(hostname) description: Machine hostname. type: string keep_artifacts: default: false description: Keep temporary log files generated during the job after being sent to coralogix. type: boolean private_key: default: CORALOGIX_PRIVATE_KEY description: Private key provided by Coralogix (under Settings --> Send Your Logs). type: env_var_name subsystem: default: workflow-stats description: Your subsystem name. type: string steps: - workflow: circle-token: <<parameters.circle-token>> keep_artifacts: <<parameters.keep_artifacts>> - send: application: <<parameters.application>> category: <<parameters.category>> endpoint: <<parameters.endpoint>> file: /tmp/coralogix/workflow-stats.log hostname: <<parameters.hostname>> private_key: <<parameters.private_key>> subsystem: <<parameters.subsystem>> examples: logs: description: | This example shows how you can debug a workflow job in Coralogix. By adding our Orb and the coralogix/logs job at the end of the flow, you'll receive all logs CircleCI generates during the workflow in your Coralogix account, helping you debug the different jobs. Note that this may generate a large amount of data, and is recommended for debugging purposes only. usage: version: "2.1" orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Typical build job" workflows: your-workflow: jobs: - build - coralogix/logs send: description: | This example shows how you can send additional 3rd party logs generated during your workflow job to Coralogix. By adding our Orb and the coralogix/send step, you can send additional logs from an external file to your Coralogix account. This is especially useful if one of the stages of your job generates an external file with logs which you'd like to report to Coralogix and analyze along with the rest of your logs. usage: version: "2.1" orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Build the application" > build.log - coralogix/send: file: build.log workflows: your-workflow: jobs: - build stats: description: | This example shows how you can send the final report of a workflow job to Coralogix. By adding our Orb and the coralogix/stats job at the end of the flow, you'll receive the report automatically in your Coralogix account and can analyze and aggregate the results. usage: version: "2.1" orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Typical build job" workflows: your-workflow: jobs: - build - coralogix/stats tag: description: | This example shows how you can create a tag (and a report) for the workflow in Coralogix. By adding our Orb and the coralogix/tag step, you can create tag (and a report) for this workflow in your Coralogix account to understand what effect it has on your production. Learn more at https://coralogix.com/tutorials/software-builds-display/ usage: version: "2.1" orbs: coralogix: coralogix/coralogix@x.y.z jobs: build: docker: - image: cimg/base:stable steps: - run: echo "Build the application" deploy: docker: - image: cimg/base:stable steps: - run: echo "Deploy the application" - coralogix/tag: application: MyApp subsystems: frontend,backend tag: v1.0.0 test: docker: - image: cimg/base:stable steps: - run: echo "Test the application" workflows: your-workflow: jobs: - build - test: requires: - build - deploy: requires: - test
開発者向け最新情報
ビルド最適化のためのヒントを手に入れましょう。
または、リサーチパネルに参加して フィードバックをお寄せください。
このフォームを送信することで、当社の利用規約およびプライバシーポリシーに同意したものと見なされます。