Logging in a custom Airflow operator - airflow

I created my own custom operator and I'm doing logger.info(), self.log.info(), and print() and I don't see where these are logged. If I look in http://localhost:8080/log/list/... I don't see anything. What am I doing wrong?

The Browse -> Logs (or http://localhost:8080/log/list/... ) is an event log. It's not a task log.
self.log.info() should work.
It's shown in the task instance log.
Graph View -> click on a task -> click on View Log it will direct you to this Log tab:
You can also find it with:
http://localhost:8080/log?task_id=YOUR_TASK_ID&dag_id=YOUR_DAG_ID&execution_date=EXECUTION_DATE

Related

Send HTTP request when a computer is added to Active Directory

I'm going to start working with Active Directory (first time in my life) with python ldap3 library. I've searched the internet for a while but couldn't find any solution for my question. I want to send a request when a computer is added to AD. I've found this event that might solve my problem but I've no idea what is this or how can I use this for my problem.
Thanks for answers.
That is an event in the Windows Security Event Log on the domain controller.
Windows does allow you to trigger a scheduled task on an event. To do what you want to do, you could set up a scheduled task on each domain controller.
In Task Scheduler:
Click "Create Task"
Click the "Triggers" tab, then "New..."
For "Begin the task", select "On an event"
In "Log", select "Security, and for "Event ID" put "4741"
Click "OK"
Then on the "Actions" tab is where you tell it what you want it to do when that event happens. You can run anything you want. You can write a PowerShell script if you want. Just search Google for "run PowerShell script from scheduled task" if that's the way you want to go.

How do I know who changed my Cloud Function

Yesterday, on a beautiful Saturday, I was resting. When suddenly the phone rings and the "system has stopped working".
When I observed the "cloud functions" one of them had an upload that I did not do, probably another member of the team.
After all, I was resting!
Now, my manager wants the deployment history for all functions.
How to know and where to get this information?
Entering the "cloud function" I can even see that there was the deploy, but it does not say "which user did it".
There are audit logs kept for all user actions. You can determine who updated the function by:
Go to Logging > Logs Explorer
In the Query Builder text box, add the following search term:
protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
Click the Run Query button and then filter down by the date and time of when it was deployed and you'll see the user's email in the principal_email property.
#Brian's answer is good. But here's another way to check Audit logs and see all operations happening on Cloud Functions:
Go to Navigation Menu > Home > Activity
Go to Filter Categories on the right part of the screen and make sure all Activity types are selected (checking only Data Access and configuration works fine as well).
Click Resource type and uncheck all but don't click OK yet.
Type to filter "Cloud Function" then check it.
Click OK.
In logs for the functions you have the information about deployment it should look something like that:
{"#type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{"principalEmail":"EMAIL#gmail.com"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/ffunctions-nodejs/locations/us-central1/functions/CRON_1440_OptimisationCall"}
I would start with reviewing this information (it is on the Console -> Project -> Functions -> logs)
Down the rabbit hole, we can go into console.cloud.google.com (Console -> Project -> Functions -> click on the three dots and go "Detailed usage statistics").
not really sure what you can dig in there though
Go to the Logs explorer and paste the below to find the updaed users of the cloud function.
resource.type = "cloud_function"
resource.labels.function_name = "your_cloud_function_name"
protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
Hope this helps!!

Google Cloud Function logs showing error icon for Info log types

I am new to google-cloud and to stack driver logging. deployed a python script as cloud function also enabled in-built logging for python. I had set multiples logs based on the execution.
logging.info("Cloud fucntion was Triggerred on time {}".format(datetime.utcnow()))
While viewing in cloud function logs, i see many, like even the statement above, for which I have set INFO as the log level is displayed with !! icon which according to the legends should be displayed for only error types.
As I am new to this stack-driver logging, I am not sure of the reason, can anyone please explain? Thanks.

Drive Table internal error. The developer of this script needs to provide additional authorizations before it can run

I'm trying to add a simple Drive Table model to a clean project, but as soon as I do that and launch a preview, I start getting this error in the log at launch and the app is essentially dead in the water.
I've tried to figure out what this error actually implies and what I'm supposed to do about it, but so far I've only managed to fail spectacularly.
I'm also getting some warning about appmaker.dataservice.brix.RealtimeCaller which doesn't look like anything to me, but might be related to the problem.
Here is the full error log (TestDB is the name of the model in this case):
(W) appmaker.dataservice.brix.RealtimeCaller: Realtime connection: HTTP status code is not available.
(W) appmaker.dataservice.brix.RealtimeCaller: Realtime connection: HTTP status code is not available.
(E) Drive Table internal error. Please try again. Caused by: The developer of this script needs to provide additional authorizations before it can run. (HTTP status code: unknown) Error: Drive Table internal error. Please try again.
(E) Executing query for datasource TestDB: (Error) : Drive Table internal error. Please try again.
(E) Executing query for datasource TestDB failed.
These are the steps I took to generate this error:
New Project -> Blank Application
Create Model -> Google Drive Table (name: TestDB)
NewPage -> datasource -> TestDB
Preview
Select my G Suite account
Allow app to view and manage the files in my Google Drive
Click "Review permissions" when prompted
Select my G Suite account
App launches and triggers errors.
Among other things, I've tried reloading, building a new preview, deploying, creating a new project and changing the access permissions to the model.
What am I doing wrong here?

No eventlogs from BizTalk

I've got a new production computer and installed my BizTalk app on there. The problem is that I don't see any messages in the event log, nor from my BizTalk app or BizTalk Server itself. The only message that appears in the event log is the following:
The following BizTalk host instance has initialized successfully.
BizTalk host name: BizTalkServerApplication
Windows service name: BTSSvc$BizTalkServerApplication
The source of that message is BizTalk Server. And no messages at all, even no logs about errors which I suppose already took place.
Just a quick thought incase you are still having problems.
I tried to write to the event log with a source type that didnt already exist and my BizTalk Host user account didn’t have permissions to create a new source type. This meant I never saw the entry in the event log.
E.g. (from example #Bill Osuch)
System.Diagnostics.EventLog.WriteEntry("MyBiztalkApp", "oh i did something");
Make sure either the MyBiztalkApp source exists or that your user has permissions on the event log to create it.
Also, if you have a lot of messages going through BizTalk you will probably want to implement your own logging so your event log doesn’t fill up. We used Log4Net for our implementation and a database to store messages.
If you're not getting any errors (suspended messages) as the messages process, you're not going to see anything in the app log. You could try adding an Expression shape to your orchestration and manually writing out some debug info:
System.Diagnostics.EventLog.WriteEntry("event type", "whatever...");
Does your application actually use the BiztalkServerApplication host? Check in the Biztalk Administration Console if all the host instances are indeed running. Is your application fully started? Messages are "put on hold" if your receive location is disabled for example.
To check this functionality, write to event log after every operation or shape in BizTalk orchestration.
Scenario-
Suppose you have to assigned a value to xpath of node in a map after transformation so in message assignment shape after you assign some value, you can write eventlog to admin console.
Ex. Suppose we have already initialized - "orderType" as "PO" in our expression shape and now we have to assign the value of "orderType" to the xpath of a node in our map then-
Shape- MessageAssignment(Under constructMessage Shape after transformation of map)
xpath(msgGetOrderReq, "/[local-name()='CustomerOrders' and namespace-uri()='http://example.com/EAI/IEmployee/v1.0']/[local-name()='ordertype' and namespace-uri()='http://example.com/EAI/IEmployee/v1.0']") = ordertype;
Next to this we want to print this information on the admin console so we need to write:-
System.Diagnostics.EventLog.WriteEntry("msgGetOrderReq", ordertype, msgGetOrderReq);
Build the project, Deploy and GAC it. Restart the host instance. Run the orchestration, process something and now you will be able to see the logs in admin console.
Regards
Mayank

Resources