Aggregate nginx logs across all Pantheon app containers - #1052
Open
AronNovak wants to merge 1 commit into
Open
Conversation
mariano-dagostino
requested changes
Jun 4, 2026
mariano-dagostino
left a comment
Collaborator
There was a problem hiding this comment.
@AronNovak oh good find! Looks good, but I have some changes to propose.
| protected function getLogFile(string $env) { | ||
| $pantheon_info = $this->getPantheonNameAndEnv(); | ||
| $this->_exec('$(terminus connection:info --field=sftp_command ' . $pantheon_info['name'] . ".$env) <<EOF | ||
| $site_env = $pantheon_info['name'] . ".$env"; |
Collaborator
There was a problem hiding this comment.
@AronNovak What about making the getLogFile a public method so it can be used to download logs outside the scope of checking bots?
Comment on lines
+206
to
+208
| $sftp_username = trim($this->getTerminusConnectionField($site_env, 'sftp_username')); | ||
| $sftp_host = trim($this->getTerminusConnectionField($site_env, 'sftp_host')); | ||
| $sftp_port = trim($this->getTerminusConnectionField($site_env, 'sftp_port')) ?: '2222'; |
Collaborator
There was a problem hiding this comment.
terminus connection:info site.env --format=json --fields=sftp_username,sftp_port,sftp_host
returns the 3 values we need as json format. in a single call.
| * @return string | ||
| * The field value, or an empty string when it could not be retrieved. | ||
| */ | ||
| protected function getTerminusConnectionField(string $site_env, string $field): string { |
Collaborator
There was a problem hiding this comment.
Not needed in my opinion, see the --fields param above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pantheon environments can run on multiple application containers, each keeping its own nginx logs.
getLogFile()only fetched logs from the single container returned byterminus connection:info --field=sftp_command, so the DDoS / access-log analysis saw only a fraction of the traffic.Now resolve every container IP behind the appserver hostname and aggregate their
nginx-access.loginto one file before analysis.Ref: https://docs.pantheon.io/guides/logs-pantheon/automate-log-downloads