Using greengrass-cli logs command from within a component

0

Setup details:

Greengrass V2 on ubuntu 18.04 GG Nucleus 2.9.2 with json logs, and GG Cli Deployed (2.9.2, with config "AuthorizedPosixGroups": "ggc_group")

I would like to be able to check a greengrass component's logs from within a greengrass component. I am already successfully using the greengrass-cli from one component to restart another.

Is it possible to run:

/greengrass/v2/bin/greengrass-cli logs get --verbose \
    --log-file /greengrass/v2/logs/<componentName>.log \
    --time-window -10sec

from another component ? When i run that, I get the error: Cannot find file: /greengrass/v2/logs/<componentName>.log''.

Does the logfile itself have to be readable by the ggc_user in order to use the logs command on it ?

asked a year ago226 views
1 Answer
0
Accepted Answer

That log directory is only readable by root by default. ggc_user won't be able to access it. You would need to run your component as root as well. Standard disclaimer: please understand the security implications if you choose to go that route. I would not recommend it.

Alternatively, you could configure the other component to log directly to a readable directory, rather than printing to stdout and having Nucleus write the logs to disk. Is this an option for you?

AWS
answered a year ago
  • That is an option, though it would have been nice to be able to use the existing greengrass logs, from within greengrass logs. Thanks for the answer.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions