Skip to content

Add preserve_fqdn to SYSLOG_CONFIG and toggle long/short hostname#25523

Open
spandan-nexthop wants to merge 1 commit intosonic-net:masterfrom
spandan-nexthop:spandan-nexthop.add-fqdn-syslog
Open

Add preserve_fqdn to SYSLOG_CONFIG and toggle long/short hostname#25523
spandan-nexthop wants to merge 1 commit intosonic-net:masterfrom
spandan-nexthop:spandan-nexthop.add-fqdn-syslog

Conversation

@spandan-nexthop
Copy link
Copy Markdown

Add preserve_fqdn to SYSLOG_CONFIG and update hostname in rsyslog-config.sh such that the remote syslog messages have the long/short hostname accordingly.
Fixes #23863
[CLOSED] Original PR was #23864.

Why I did it

The original PR was #23864.
This was closed since the changes for hardcoding the hostname got committed as part of #24394

Currently, in SONiC, syslog messages are only sent with the shortened hostname, not the FQDN. It would be good to conditionally be able to toggle the hostname to the long (FQDN) or short form in remote syslog messages.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  • Added a new leaf - preseve_fqdn - to SYSLOG_CONFIG in sonic-syslog.yang
  • Since any change inside SYSLOG_CONFIG|GLOBAL automatically triggers an rsyslog-config restart, I just added a check for preserve_fqdn in rsyslog-config.sh such that it sets the hostname to the long/short form correctly.
  • Note that, adding PreserveFQDN on|off in the syslog config would have been an alternate solution, but that approach requires an update and restart of rsyslog in the host AS WELL AS all the containers separately since each run their own syslog daemon. This was a more disruptive solution and we chose to not go down that path.

How to verify it

Enabling preserve_fqdn and doing a tcpdump for the syslog messages shows the correct FQDN.

host$ show syslog
SERVER IP    SOURCE IP    PORT    VRF
-----------  -----------  ------  -----
10.11.0.5    N/A          N/A     N/A
10.11.0.6    N/A          N/A     N/A

host$ sonic-db-cli CONFIG_DB HSET "SYSLOG_CONFIG|GLOBAL" "preserve_fqdn" "true"
1

(snmp)root@host:/# logger --priority CRIT "Test syslog message from snmp container MSG1"

23:50:54.629484 lo    In  IP localhost.38482 > localhost.syslog: SYSLOG user.critical, length: 104
E.....@.@..H.........R...p..<10>2025-07-31T23:50:54.629330+00:00 <host_FQDN> snmp#root: Test syslog message from snmp container MSG1
23:50:54.629610 eth0  Out IP 10.250.15.2.36470 > 10.11.0.5.syslog: SYSLOG user.critical, length: 130
E....!@.@.M"

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

Adding preserve_fqdn to SYSLOG_CONFIG to conditionally toggle the full/short hostname sent in syslog messages.

Link to config_db schema for YANG module changes

https://github.com/spandan-nexthop/sonic-buildimage/blob/spandan-nexthop.add-fqdn-syslog/src/sonic-yang-models/yang-models/sonic-syslog.yang#L184

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 91e61ff to 6e76376 Compare February 15, 2026 19:53
@spandan-nexthop
Copy link
Copy Markdown
Author

spandan-nexthop commented Feb 15, 2026

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 6e76376 to f197086 Compare February 15, 2026 19:56
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from f197086 to 0761628 Compare February 16, 2026 16:41
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 0761628 to 745242a Compare February 19, 2026 18:45
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop
Copy link
Copy Markdown
Author

/azpw run

@mssonicbld
Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@spandan-nexthop
Copy link
Copy Markdown
Author

/azpw retry

@mssonicbld
Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@yijingyan2
Copy link
Copy Markdown
Contributor

/azpw retry

@mssonicbld
Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld
Copy link
Copy Markdown
Collaborator

Build not found. Please close and reopen the PR or rebase your branch to trigger a new build.

@yijingyan2
Copy link
Copy Markdown
Contributor

Hi @spandan-nexthop, your build was triggered one month ago. The build has been cleaned already. Please close and reopen the PR or rebase your branch to trigger a new build. Thanks

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@yxieca
Copy link
Copy Markdown
Contributor

yxieca commented Apr 7, 2026

/azpw ms_conflict

1 similar comment
@yxieca
Copy link
Copy Markdown
Contributor

yxieca commented Apr 8, 2026

/azpw ms_conflict

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 471bc79 to 4f4413c Compare April 9, 2026 17:22
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 4f4413c to 634b532 Compare April 15, 2026 23:59
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

…log-config.sh` such that the remote syslog messages have the long/short hostname accordingly

Signed-off-by: Spandan Chowdhury <spandan@nexthop.ai>
@spandan-nexthop spandan-nexthop force-pushed the spandan-nexthop.add-fqdn-syslog branch from 634b532 to fb524fc Compare April 29, 2026 23:24
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop
Copy link
Copy Markdown
Author

/azpw retry

@mssonicbld
Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld
Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1101788:

✅Stage Test:

  • Job impacted-area-kvmtest-t1-lag by Elastictest: retried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Remote syslog messages should include FQDN

4 participants