Open pacamaster opened 8 months ago
After thinking this over more, think mysql syntax is not correct. It is setting Alias for the table, not the column. Correct decorators-
SELECT uuid AS host_uuid FROM system_info;
SELECT hostname AS hostname FROM system_info;
SELECT hardware_serial AS serial_number FROM system_info;
This would require linting SQL statements INSIDE the yaml file.
@sharon-fdm @pacamaster Looks like this issue changed from a bug to a feature request: Lint SQL statements inside agent options
Should we take it through feature fest?
@getvictor The original statement from customer was "I had an error the linter didn't catch" but I don't really think this is a bug.
The actual state was: the linter IS validating yaml in this file. The decorator takes a SQL query. The linter IS NOT validating SQL IN the yaml file.
To fulfill this request we would need to have validation of both the yaml & any SQL strings in key/vals IN the yaml. That seems like it would be hard but we kind of need an level of effort estimate to know if my hunch is correct. Thanks.
SQL linting would be useful for any API/fleetctl interactions that save queries/policies. For example, recently we put in a misformatted policy query via gitops flow and didn't catch it for a few days.
Assigning @noahtalerman to prioritize.
I am all for it if you think this kind of validation is valuable. Thanks!
Thanks all!
Removing the bug label because we decided this is a feature request.
@noahtalerman We may want to make the title more general as this isn't (per @getvictor) really a problem specific to decorators or logs. It's more about adding additional SQL parsing / linting for yaml configuration file inputs. Thanks.
@nonpunctual I think let's keep it specific to decorators and file separate stories for adding parsing to other areas.
This way, we can work on the decorators fix first.
At Fleet, we want to make iterative improvements so that we can ship value quickly.
Fleet version: <!-- Copy this from the "My account" page in the Fleet UI, or run
fleetctl --version
--> 4.47.3 current stable fleetd agent (osquery 5.11.0, Orbit 1.22.0) Web browser and operating system: Current macOS and Chrome browser💥 Actual behavior
Decorators do not seem to be updating for query result logs. Using a query that ingests the ATC table in the above config works, but the decorators are not being updated AS
serial_number
. The ASserial_number
was in the agent options config before the ATC table was added to the config. The data is modeled forserial_number
but displays ashardware_serial
and the client has ended up with a mix of data withserial_number
andhardware_serial
. These keys are important to tag in their ingestion and when expecting a value gets set tonull
and is extra work for them. Confirmed this host is part of the "no team" so the above agent options should apply.🧑💻 Steps to reproduce
🕯️ More info (optional)
Overlooked that was setting alias to the table and not columns.
~~The hunch is that decorators when changed in config is not updating on
load
. In the meantime, we had them change decorators toalways
on a canary team to see if this loads. They did state they had set it tohardware_serial
at first and saw this same trouble. Changed decorator toserial_number
, then they redeployed the agent package with--enable_scripts
for a separate issue, saw the decorators update on their No Team devices- but now it seems to have converted back to the decorator forhardware_serial
.~~Also confirmed with tagged client that there is not some other platform managing their osquery config (Chef, Ansible, etc).Currently waiting for a scheduled query to run and see if data from the canary team is valid. If this is the case then would suggest aninterval
setting with 6-12 hr🛠️ To fix
SELECT hardware_serial AS serial_number FROM system_info;