On 08/08/2022 09:58, nina guo wrote:
But the following 3 lines should be appended to a file first, then
next time override the old content. But how to make the old content be
overried by previous ones?
print (" # HELP ldap_query_success LDAP query command",
file=open("/var/log/node_exporter/filecollector/ldap_query.prom", "a+"))
print (" # TYPE ldap_query_success gauge",
file=open("/var/log/node_exporter/filecollector/ldap_query.prom", "a+"))
print
('ldap_query_success'+'{'+'ldap_uri'+'='+service+','+'ldap_search_base'+'='+ldap_search_base+','+'}
'+str(query_check),
file=open("/var/log/node_exporter/filecollector/ldap_query.prom", "a+"))
File mode "a" will open for appending (so preserve anything already in
the file). Instead to fully replace the file you'd need to use file mode
"w".
--
Stuart Clark
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/c7354142-2105-dd77-721c-255d557cc058%40Jahingo.com.