https://slingdata.io logo
m
Hi, 2 questions. 1. If I save the incremental value in state table with "SLING_STATE" Is there a way to manipulate the value before the stream begin? - I tried but it updates the value again for the last value again. We need to add abilite to load data incrementaly with retro active gap as I already mentioned here previously.. And the approach the do it in sql in every stream isnt ideal. So I though to run change the value before the stream is start, but it looks like the stream is changing the value again when it starts. 2. How can we parse the incremental value to the query hook, we building monitoring process and this information can be very usefull for us.
f
hi @marikt94 did you try the
pre
hook? assuming your using a DB for sling state. you can simply execute an UPDATE in the
pre
hook to change the state value.
Copy code
streams:
   my_stream:
     hooks:
       pre:
         - type: query
           connection: my_state_conn  # same connection you use for SLING_STATE
           query: |
              UDPATE my_schema._sling_state set ... where source_stream = '{stream.name}'
for #2, what do you mean by parsing?
it's usually a timestamp or something
oh I see, you mean "passing"... ah ok let me see
m
Hi, thanks for reply. sorry forgot to update that 1# question already solved.. Waiting for 2# 🙏
f
OK this is added for next release (should be in latest dev build in 10min), you will be able to use
{ date_format(run.incremental_value, "%Y-%m-%d") }
m
Great, it works perfect! I have another question based on docs of log hooks, I saw there something that can also parse the cpu and memory usage and also io, but the value came from state, so I dont sure if tis something is built on sling. Anyway, is there any option to receive that information as log but for query? The reference: hooks: post: - type: log message: | Resource Usage for {run.stream.name}: - Memory Used: {state.resource_check.result.memory_used} - CPU Usage: {state.resource_check.result.cpu_usage}% - Disk IO: {state.resource_check.result.disk_io_bytes} bytes level: debug https://docs.slingdata.io/concepts/hooks/log#id-9.-resource-usage-logging-post-hook
If we can receive such information it will be very powerfull for us
f
hey @marikt94 , this aactually just an example, sling does not have this built in. You could build this maybe with python or something? and then call it with the
command
hook with
capture=true
and grab a json output from
stdout
. And use the
json_parse
function to convert to object.
m
Hi, I can see it on my log, where it comes from? The MEM & CPU Usage? Is it something new? If so, how can I access this data while running sling? https://cdn.discordapp.com/attachments/1435728756848328766/1440780565467889664/image.png?ex=691f66f7&is=691e1577&hm=9a51209117c0ef0ad3951994f55dd18ee4cf9405759184c73b50a33fb70d992c&
f
hey, no this has been there for a long time. you can't access, it's happening outside of the hooks space, I would need to rewrite things.
m
In a way it would be accessable? Or doesnt relates..
f
I think the easiest might be to create a function, like
machine_stats()
to return the memory & cpu values