Getting the results from custom code

How do we get the results of custom code ?

I suppose is choosing the right “Returner” from the list here https://docs.saltstack.com/en/latest/ref/returners/all/index.html … but firstly the default “cloud” isn’t documented there and its not clear how to set arguments in my.autopi.io ( for example for smtp_return ).

I’ve tried “local” and “local.event_return” but its not clear how this works.

Thanks.

Hi Peter

The cloud returner will buffer the data and then push it to the autopi cloud.
Currently it’s possible to set any returner you want, but unfortunately most returners requires some additional configuration in the minion configuration file, and this is currently managed from the cloud - and not really possible to modify on the device without it being overwritten when the minion process restarts.

So if the returner needs no additional configuration it can be used, but I’m not sure if there exists any returners that doesn’t expect some additional configuration.

Can you explain what you are trying to achieve?

The cloud returner will take any data you send it, and send it to the cloud, so if you have a module called

my_rainsensor

with a function called

get_mm_of_rain

you can have a job that runs the function by calling my_rainsensor.get_mm_of_rain
and if any arguments is required, those can be configured in the args field, and the same for kwargs (just remember that kwargs should be in the format some_kwarg=123

Best regards
/Malte

So once done, how can the data be viewed ? Where does the cloud data go ?

Automatically run a function and view the result somewhere.

Thanks for that - the docs ( eg https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.smtp_return.html ) imply json format … am I missing some other docs on this ?

Put it another way, is there a way to configure a job or custom code so that the results ends up in the events list ? I’ve tried some of the documented retainers but I didn’t see anything.

Obviously the end game is to see the results of jobs and custom code nicely graphed in the Dashboard view and we arn’t there yet, but it will be useful to be able to view the results somehow pending this so we can explore what data is available from the car.

Hi Peter

Okay

It will be stored on our cloud storage system, and then (soon) you will be able to configure the dashboard to load your custom data, and display it in a chart etc. So when a job executes, and the returner is set to ‘cloud’ - the result is (today) uploaded to our cloud and stored - but you are unfortunately not yet able to retrieve it.

When setting up a job, you can set specific arguments to that job, but I don’t believe it’s possible to pass parameters to the returner - at least not via the --return_kwargs argument.
So you could go and add the necessary configuration fields to the minion config. Currently the minion config lives on the cloud, and is retrieved to the minion on startup, so it will overwrite any local changes.

But it may be possible to have custom sections of the minion config in the minion.d directory inside /etc/salt/minion, but this is solely a saltstack feature and is not yet managed and or supported by us.

Events
You can actually fire events from the custom modules, but only events with a specific prefix are uploaded to the cloud.
But it’s a great idea to be able to fire custom events and show them in the events list. To be able to do so we are adding a custom prefix that people can use to create custom events.
To see an example of sending events, you can check out the core repository on github

Saltstack documentation about sending events.
https://docs.saltstack.com/en/latest/topics/event/events.html#firing-events-from-python

Timeline
We have a new release coming out monday (i hope) with a bunch of stuff - and the next thing I will start working on after the release, is being able to retrieve all custom data from the API, and show it in the configurable dashboard.
So we are talking weeks, not months before you will be able to retrieve the data in the API and configure the dashboard to show it in a chart.

Many thanks … I’ll keep up-to-date with the releases and try again in a few weeks :slight_smile:

Is this now available? and where?

1 Like