Conversation
…names This update introduces an optional 'alias' field to the machines.json configuration schema, allowing human-friendly names to be displayed in Slack messages and log output instead of machine names. Changes to Machine Model (src/dm_mac/models/machine.py): - Added 'alias' field to CONFIG_SCHEMA as optional string - Added 'alias' parameter to Machine.__init__() - Added display_name property that returns alias if present, else name - Updated MachinesConfig to build machines_by_alias lookup dictionary - Added get_machine() method to support lookup by name or alias - Updated all MachineState logging to use machine.display_name Changes to Slack Handler (src/dm_mac/slack_handler.py): - Updated machine_status() to display aliases in status output - Updated all log_* methods to use machine.display_name in messages - Modified oops(), lock(), and clear() commands to accept multi-word aliases by joining command parts with spaces - Updated handle_command() to support commands with >= 2 parts - Changed get_machine() calls to use new MachinesConfig.get_machine() method instead of direct machines_by_name dictionary access Test Updates: - Added alias to metal-mill in tests/fixtures/machines.json - Added tests for Machine.display_name property behavior - Added TestMachinesConfigGetMachine class with tests for lookup by name, alias, and non-existent machines - Added test_handle_command_oops_by_alias() for alias command support - Updated all Slack message assertions to expect aliases instead of machine names where applicable Documentation Updates: - Updated CLAUDE.md with alias field description and lookup behavior - Updated docs/source/configuration.rst with alias field explanation - Updated docs/source/slack.rst to document alias support in commands All 155 tests passing with 99% coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jantman
added a commit
that referenced
this pull request
Nov 30, 2025
…oard
This commit adds a display_name label to all machine-based Prometheus metrics,
in addition to the existing machine_name label. The display_name uses the
machine's alias if configured, otherwise falls back to the machine name. This
provides human-friendly names in dashboards and queries while preserving the
technical machine_name for filtering and querying.
Changes to Prometheus Metrics (src/dm_mac/views/prometheus.py):
- Added display_name label to all 19 machine-specific metrics
- Both machine_name and display_name labels are now present on all metrics
- Used m.display_name property which returns alias if set, otherwise name
- Labels are alphabetically sorted: display_name, machine_name
Test Updates (tests/views/test_prometheus.py):
- Updated all expected metric outputs to include both labels
- Metal Mill machine shows display_name="Metal Mill" (uses alias)
- Other machines show display_name equal to machine_name (no alias)
- LED metrics updated to include display_name in addition to led_attribute
Documentation Updates (docs/source/admin.rst):
- Updated all metric examples to show both labels
- Examples now reflect the display_name label in output
- Metal Mill consistently shows display_name="Metal Mill"
Grafana Dashboard Updates (docs/source/grafana-dashboard.json):
- Changed all legendFormat from {{machine_name}} to {{display_name}}
- Updated template variable query to use display_name
- Dashboard now shows human-friendly names (aliases) in legends and labels
- Machine selector dropdown uses display_name for better UX
Dashboard Documentation (docs/source/grafana-dashboard.md):
- Updated metrics table to show both labels for machine metrics
- Updated template variable description
- Clarified that display_name uses alias if present
Benefits:
- Dashboards show human-friendly "Metal Mill" instead of "metal-mill"
- Preserves machine_name for programmatic filtering/querying
- Backward compatible - both labels available for PromQL queries
- Consistent with existing display_name property from PR #69
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
This PR introduces an optional
aliasfield to themachines.jsonconfiguration schema, allowing human-friendly names to be used in Slack messages and log output instead of machine names.Key Changes
aliasfield to configuration schema withdisplay_nameproperty that returns alias if present, otherwise machine nameget_machine()method toMachinesConfigthat supports lookup by either machine name or aliasdisplay_namefor better readabilityBackwards Compatibility
Machines without an
aliasconfigured continue to work exactly as before, using the machine name in all contexts.Test Plan
Machine.display_namepropertyMachinesConfig.get_machine()lookup method🤖 Generated with Claude Code