Hey fleet team, We are suffering a weird issue. Th...
# fleet
j
Hey fleet team, We are suffering a weird issue. That is osquery Config API will update host intervals (distributed_interval, logger_tls_period, config_refresh). But, at the same time, distributedWrite will also update the same fields in osquery_flags query. That means if we change our these three intervals in table app_config_json. distributedWrite will write it back to what osquery_flags configured. This looks not correct, please help to give us some advises. Thanks!
k
Hi @Jian Zheng! Can you walk me through what you’re doing on your end step by step? The distributed write is likely a red herring here as that is just osquery checking in with query results and there aren’t any queries that would result in changes to the Fleet app config or the osquery config sent to hosts.
j
Hey @Kathy Satterlee, Thanks for response! 1, I changed my app_config_json with some updated intervals value. it's expected that the config API will update Hosts DB record with those in interval fields. The DB record did update by Config API. 2. However, I noticed that the host DB record intervals fields changed back to old values. I think this is because, one distributed write API called and update the host record with those with osquery_flags query result. The weird thing is both Config API and distributed write update the same fields of host DB record. But, their data source is from different places.
k
When you say “host DB record”, do you mean the Fleet database, or the host’s local osquery database?
j
Fleet database
k
Can you send over some screenshots showing that data changing? I think I’m missing a key point somewhere.
Feel free to dm those to me.
Also, does the Fleet app config still show the updated values?
If you could share the config as well, that might be helpful.
j
I think code may help you to understand this case: Config Updated interval here: https://github.com/fleetdm/fleet/blob/main/server/service/osquery.go#L501-L505C3 Distributed write update the intervals here: https://github.com/fleetdm/fleet/blob/main/server/service/osquery_utils/queries.go#L199 So in the case, Config API updates the host intervals source from app config json. Then right after osquery_flags result in distributed write also try to update the intervals fields. At the end, host intervals field will change back by distributed write.
k
Yes, that would update the host details, but it would just reflect the current state of the host. It still sounds like the root of the issue is that the config isn’t applying correctly.
If you look at your agent options in the Fleet UI, does that reflect the correct values for the intervals?
We can hop on a quick Zoom call if you like so we don’t get bogged down in terminology :)
I realize that’s part of the trouble we’re running in to.
But the main point is that the detail query for osquery_flags is just informational. It’s reading the current flags set in the host, but not changing settings in Fleet or on the host. If the host isn’t returning the value you’re setting, the breakdown is happening somewhere with the osquery config. Either that isn’t set up properly in Fleet, or the agent isn’t retrieving it properly.
When osquery checks in for new config, the intervals set in the
hosts
table have no effect on the config Fleet sends.
So the questions to focus on are: 1. Is the saved app configuration changing? 2. How are you applying the configuration when making changes? 3. If you’re using plain osquery, what flags are you setting? 4. Are you seeing any errors in Fleet or osquery? 5. What is your current setup for agent options?
Also, sorry I forgot about that detail query! That makes a lot more sense now.
w
@Kathy Satterlee the question is once osquery config API change the app_config_json with a new val, why distributed_write would change it back? if you check the logic of distributed_write, you can see that distribtued_write traverse all the detail query includes osquery_flags which comes from agent, and the val in it comes from osquery flags file, so even we change the value by agent options, the value in hosts table will be covered with original value after a while. I want to know why would it happen?
@Kathy Satterlee the issue is not whether we have issue in our config, the issue why fleet goes like this, why the code of osquery config API change hosts table, but distributed_write API change it back?
k
If the config applied correctly, the value returned by the detail query would be the value set in the config.
It would go: The config is set in fleet The config plugin checks in and gets the new config The detail query runs and gets the value, which was set by the config.
w
ok i get your points, so the problem is the cfg not applied, so the result of detail query returns the original val, and cover back the data in hosts table.
k
Exactly. Somehow, the config is changing on the host.
Or not applying in the first place.
When I change an interval in Fleet, I confirm it applied by checking the host details or querying
osquery_flags
.